diff --git a/BUILD.gn b/BUILD.gn index 3f503cae758e786b05151adcdae94037949e8065..2109f48749762a57f06f113e81f5afe2e44f1d8d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -68,6 +68,7 @@ template("ohos_declaration_template") { action_with_pydeps(target_name) { script = "//interface/sdk-js/remove_internal.py" input_api_dir = "//interface/sdk-js/api" + inputs = [ "//interface/sdk-js/api" ] outputs = [ root_out_dir + "/ohos_declaration/$target_name" ] if (sdk_build_public) { script = "//out/sdk-public/public_interface/sdk-js/remove_internal.py" diff --git a/README_zh.md b/README_zh.md index 21846d91b8adec8fa349e614fb8dd3fb7ddfc319..07a08fd8e211925e6fc25b6848daf595bf48e5c5 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,8 +1,31 @@ -# API声明文件公共仓 +# API声明文件公共仓 -- [简介](#section11660541593) +## 简介 -## 简介 +JS/TS API 公共仓,用来提交 API d.ts 声明文件以及API相关工具。 -JavaScript API 公共仓,用来提交 API d.ts 声明文件。 +## 目录 + +``` +├─api +| ├─@internal +│ | ├─component +│ | | └─ets #基于TS扩展的声明式开发范式组件声明文件 +| | └─ets +| ├─config #基于JS扩展的类Web范式 +| ├─form #JS服务卡片 +| ├─@ohos.×××.d.ts #API声明文件 +| └─@system.×××.d.ts #标记为停止维护的接口 +├─build-tools + ├─api_check_plugin #检查API规范的工具 + | ├─plugin + | ├─src + | └─test + └─collect_application_api #解析应用到的API的工具 + └─src +``` + +## 相关仓 + +[interface-sdk_js](https://gitee.com/openharmony/interface_sdk-js/tree/master) diff --git a/api/@internal/component/ets/common.d.ts b/api/@internal/component/ets/common.d.ts index d8623f93e04e119abb220a20d548d86cb680bbdc..199a372cb9fb1879f9fa082ecdbea26e736f3432 100644 --- a/api/@internal/component/ets/common.d.ts +++ b/api/@internal/component/ets/common.d.ts @@ -146,7 +146,17 @@ declare function getContext(component?: Object): Context; * @since 9 */ declare type Context = import('../api/application/Context').default; - + +/** + * Post Card Action. + * @param { Object } component - indicate the card entry component. + * @param { Object } action - indicate the router or message event. + * @StageModelOnly + * @systemapi + * @since 9 + */ + declare function postCardAction(component: Object, action: Object): void; + /** * Defines the data type of the interface restriction. * @since 7 @@ -629,7 +639,7 @@ declare namespace focusControl { * Request focus to the specific component by param: 'id/key'. * @since 9 */ - declare function requestFocus(value: string): boolean; + function requestFocus(value: string): boolean; } /** @@ -668,6 +678,28 @@ declare enum SourceType { TouchScreen, } +/** + * Defines the event tool type. + * @since 9 + */ +declare enum SourceTool { + /** + * Unknown type. + * @since 9 + */ + Unknown, + + /** + * The finger type. + */ + FINGER, + + /** + * The pen type. + */ + PEN, +} + /** * Defines the Border Image Repeat Mode. * @since 9 @@ -747,6 +779,29 @@ declare interface BaseEvent { * @since 8 */ source: SourceType; + + /** + * Touch pressure. + * @since 9 + */ + pressure: number; + + /** + * The angle between pencil projection on plane-X-Y and axis-Z. + * @since 9 + */ + tiltX: number; + + /** + * The angle between pencil projection on plane-Y-Z and axis-Z. + * @since 9 + */ + tiltY: number; + + /** + * The event tool type info. + */ + sourceTool: SourceTool; } /** @@ -1713,6 +1768,8 @@ declare class CommonMethod { /** * Sets the number of occupied columns and offset columns for a specific device width type. * @since 7 + * @deprecated since 9 + * @useinstead grid_col/[GridColColumnOption] and grid_row/[GridRowColumnOption] */ useSizeType(value: { xs?: number | { span: number; offset: number }; @@ -2020,26 +2077,17 @@ declare class CommonShapeMethod extends CommonMethod { * @since 9 */ declare interface LayoutBorderInfo { - borderWidth: number, + borderWidth: EdgeWidths, margin: Margin, padding: Padding, } -/** - * Sub component position info. - * @since 9 - */ -declare interface LayoutPosition { - x: number, - y: number, -} - /** * Sub component layout info. * @since 9 */ declare interface LayoutInfo { - position: LayoutPosition, + position: Position, constraint: ConstraintSizeOptions, } @@ -2076,7 +2124,7 @@ declare interface LayoutChild { * Sub component position. * @since 9 */ - position: LayoutPosition, + position: Position, /** * Call this measure method in onMeasure callback to supply sub component size. @@ -2148,6 +2196,13 @@ declare class CustomComponent extends CommonAttribute { * @since 7 */ onBackPress?(): void; + + /** + * PageTransition Method. + * Implement Animation when enter this page or move to other pages. + * @since 9 + */ + pageTransition?(): void; } /** 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 446c40e25b2e6c7a5f7061b6e67194e0713498ef..a1c780576a00adda899a4b44b1e7dbc8575b1b27 100644 --- a/api/@internal/component/ets/common_ts_ets_api.d.ts +++ b/api/@internal/component/ets/common_ts_ets_api.d.ts @@ -81,9 +81,17 @@ declare class AppStorage { /** * Called when a cleanup occurs. * @since 7 + * @deprecated since 9 + * @useinstead AppStorage.Clear */ static staticClear(): boolean; + /** + * Called when a cleanup occurs. + * @since 9 + */ + static Clear(): boolean; + /** * Called when the data can be changed. * @since 7 diff --git a/api/@internal/component/ets/enums.d.ts b/api/@internal/component/ets/enums.d.ts index 4485ed6929a68744047ec61af4e3feaa89f775ff..0316ba0eb6b73241860e168fecb608f29322be67 100644 --- a/api/@internal/component/ets/enums.d.ts +++ b/api/@internal/component/ets/enums.d.ts @@ -507,6 +507,7 @@ declare enum Edge { /** * Center horizontal and vertical. * @since 7 + * @deprecated since 9 */ Center, @@ -519,6 +520,7 @@ declare enum Edge { /** * Cross axis direction text baseline alignment. * @since 7 + * @deprecated since 9 */ Baseline, @@ -531,6 +533,7 @@ declare enum Edge { /** * Middle * @since 7 + * @deprecated since 9 */ Middle, diff --git a/api/@internal/component/ets/flow_item.d.ts b/api/@internal/component/ets/flow_item.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..801acb1a9bcedfed26879927890ceb9837bbcb73 --- /dev/null +++ b/api/@internal/component/ets/flow_item.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. + */ + +/** + * Mesh container for static fixed-size layout scenarios. + * @since 9 + */ +interface FlowItemInterface { + /** + * Construct the flow item. + * @since 9 + */ + (): FlowItemAttribute; +} + +/** + * @since 9 + */ +declare class FlowItemAttribute extends CommonMethod {} + +declare const FlowItem: FlowItemInterface +declare const FlowItemInstance: FlowItemAttribute; diff --git a/api/@internal/component/ets/grid_col.d.ts b/api/@internal/component/ets/grid_col.d.ts index cb493ec093033e36f73a172fd6722e372a6a935e..e9ddfe4aa3927b3d74555dc06a10c9b3d69dd051 100644 --- a/api/@internal/component/ets/grid_col.d.ts +++ b/api/@internal/component/ets/grid_col.d.ts @@ -89,7 +89,7 @@ interface GridColInterface { * Defines the constructor of GridContainer. * @since 9 */ - (optiion?: GridColOptions): GridColAttribute; + (option?: GridColOptions): GridColAttribute; } declare class GridColAttribute extends CommonMethod { diff --git a/api/@internal/component/ets/grid_container.d.ts b/api/@internal/component/ets/grid_container.d.ts index 28203fa47f53365ea30a523ac957abe7864e6577..1c9e0cd0f4d23a98a1cc18ff575f5a9c61d08d49 100644 --- a/api/@internal/component/ets/grid_container.d.ts +++ b/api/@internal/component/ets/grid_container.d.ts @@ -16,6 +16,8 @@ /** * Defines the size type. * @since 7 + * @deprecated since 9 + * @useinstead grid_col/[GridColColumnOption] and grid_row/[GridRowColumnOption] */ declare enum SizeType { /** @@ -52,29 +54,35 @@ declare enum SizeType { /** * Defines the options of GridContainer. * @since 7 + * @deprecated since 9 + * @useinstead grid_col/[GridColOptions] and grid_row/[GridRowOptions] */ declare interface GridContainerOptions { /** * Sets the total number of columns in the current layout. * @since 7 + * @deprecated since 9 */ columns?: number | "auto"; /** * Select the device width type. * @since 7 + * @deprecated since 9 */ sizeType?: SizeType; /** * Grid layout column spacing. * @since 7 + * @deprecated since 9 */ gutter?: number | string; /** * Spacing on both sides of the grid layout. * @since 7 + * @deprecated since 9 */ margin?: number | string; } @@ -82,11 +90,14 @@ declare interface GridContainerOptions { /** * Defines the GridContainer component. * @since 7 + * @deprecated since 9 + * @useinstead grid_col/[GridColInterface] and grid_row/[GridRowInterface] */ interface GridContainerInterface { /** * Defines the constructor of GridContainer. * @since 7 + * @deprecated since 9 */ (value?: GridContainerOptions): GridContainerAttribute; } @@ -94,6 +105,8 @@ interface GridContainerInterface { /** * Defines the grid container attribute from inheritance Column * @since 7 + * @deprecated since 9 + * @useinstead grid_col/[GridColAttribute] and grid_row/[GridRowAttribute] */ declare class GridContainerAttribute extends ColumnAttribute {} diff --git a/api/@internal/component/ets/index-full.d.ts b/api/@internal/component/ets/index-full.d.ts index f536b164e2d62672de57043fec0dbaf780c78be7..fe915f8660f4115ef29dddc2e0d7078fc5e6e760 100644 --- a/api/@internal/component/ets/index-full.d.ts +++ b/api/@internal/component/ets/index-full.d.ts @@ -107,3 +107,5 @@ /// /// /// +/// +/// diff --git a/api/@internal/component/ets/list_item.d.ts b/api/@internal/component/ets/list_item.d.ts index edfea632c956d112fc14f2bc06c99b6f49c7ec13..c6f104be3208e4e9bcff2e76bf8f0d21ab8805f8 100644 --- a/api/@internal/component/ets/list_item.d.ts +++ b/api/@internal/component/ets/list_item.d.ts @@ -17,6 +17,8 @@ /** * Declare item ceiling attribute. * @since 7 + * @deprecated since 9 + * @useinstead list/StickyStyle */ declare enum Sticky { /** @@ -128,6 +130,8 @@ declare class ListItemAttribute extends CommonMethod { /** * Called when setting whether item is ceiling effect. * @since 7 + * @deprecated since 9 + * @useinstead list/List#sticky */ sticky(value: Sticky): ListItemAttribute; diff --git a/api/@internal/component/ets/nav_destination.d.ts b/api/@internal/component/ets/nav_destination.d.ts index 3868d8de29e0bfedde5d06214ce59e6e25b5ccb0..ff5b52d3a3372aaec961772ab1b32c0040600b05 100644 --- a/api/@internal/component/ets/nav_destination.d.ts +++ b/api/@internal/component/ets/nav_destination.d.ts @@ -40,7 +40,7 @@ declare interface NavDestinationCustomTitle { * Sets the custom title builder. * @since 9 */ - builder: string; + builder: CustomBuilder; /** * Sets the custom title height. @@ -55,7 +55,7 @@ declare interface NavDestinationCustomTitle { */ declare interface NavDestinationInterface { /** - * constructor. + * Constructor. * @since 9 */ (): NavDestinationAttribute; diff --git a/api/@internal/component/ets/nav_router.d.ts b/api/@internal/component/ets/nav_router.d.ts index f6d6718aa13c1b892519e5219a5c2990a2728f8e..44ea2af9b8d3ef9ca14607b1d02c884f6bc6b72b 100644 --- a/api/@internal/component/ets/nav_router.d.ts +++ b/api/@internal/component/ets/nav_router.d.ts @@ -19,7 +19,7 @@ */ declare interface NavRouterInterface { /** - * constructor. + * Constructor. * @since 9 */ (): NavRouterAttribute; diff --git a/api/@internal/component/ets/navigation.d.ts b/api/@internal/component/ets/navigation.d.ts index 74d0480687986f96314cd1efe105e1a108112c4c..3cec4a169d5aed8a02e80e1fb0e000873c44dd27 100644 --- a/api/@internal/component/ets/navigation.d.ts +++ b/api/@internal/component/ets/navigation.d.ts @@ -40,7 +40,7 @@ declare interface NavigationCustomTitle { * Sets the custom title builder. * @since 9 */ - builder: string; + builder: CustomBuilder; /** * Sets the custom title height. diff --git a/api/@internal/component/ets/rect.d.ts b/api/@internal/component/ets/rect.d.ts index 3bc5bdab97d8d3629a058ed6d2aa7fcde94cb5aa..05cdcd37badcfd59d2f6a280a1652981bdc0db60 100644 --- a/api/@internal/component/ets/rect.d.ts +++ b/api/@internal/component/ets/rect.d.ts @@ -81,4 +81,13 @@ declare class RectAttribute extends CommonShapeMethod { } declare const Rect: RectInterface; + +/** + * @deprecated since 9 + */ declare const RectInStance: RectAttribute; + +/** + * @since 9 + */ +declare const RectInstance: RectAttribute; diff --git a/api/@internal/component/ets/scroll.d.ts b/api/@internal/component/ets/scroll.d.ts index 47334f21c69678cece28301cf5c176e763107f5b..6795800e39d541250ebcca024518a9af26186f21 100644 --- a/api/@internal/component/ets/scroll.d.ts +++ b/api/@internal/component/ets/scroll.d.ts @@ -33,6 +33,7 @@ declare enum ScrollDirection { /** * Free scrolling is supported. * @since 7 + * @deprecated since 9 */ Free, @@ -72,9 +73,16 @@ declare class Scroller { /** * Called when page turning mode is set. * @since 7 + * @deprecated since 9 */ scrollPage(value: { next: boolean; direction?: Axis }); + /** + * Called when page turning mode is set. + * @since 9 + */ + scrollPage(value: { next: boolean }); + /** * Called when viewing the scroll offset. * @since 7 diff --git a/api/@internal/component/ets/water_flow.d.ts b/api/@internal/component/ets/water_flow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5387a22c519dbdf727348abd181932a23efa40b --- /dev/null +++ b/api/@internal/component/ets/water_flow.d.ts @@ -0,0 +1,100 @@ +/* + * 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 water flow options. +* @since 9 +*/ +declare interface WaterFlowOptions { + /** + * Describes the water flow footer. + * @since 9 + */ + footer?: CustomBuilder; + + /** + * Describes the water flow scroller. + * @since 9 + */ + scroller?: Scroller; +} + + +/** + * @since 9 + */ +interface WaterFlowInterface { + /** + * WaterFlow is returned when the parameter is transferred. Only support api: scrollToIndex + * @since 9 + */ + (options?: WaterFlowOptions): WaterFlowAttribute; +} + +/** + * @since 9 + */ +declare class WaterFlowAttribute extends CommonMethod { + /** + * This parameter specifies the number of columns in the current waterflow. + * @since 9 + */ + columnsTemplate(value: string): WaterFlowAttribute; + + /** + * This parameter specifies the min or max size of each item. + * @since 9 + */ + itemConstraintSize(value: ConstraintSizeOptions): WaterFlowAttribute; + + /** + * Set the number of rows in the current waterflow. + * @since 9 + */ + rowsTemplate(value: string): WaterFlowAttribute; + + /** + * Set the spacing between columns. + * @since 9 + */ + columnsGap(value: Length): WaterFlowAttribute; + + /** + * Set the spacing between rows. + * @since 9 + */ + rowsGap(value: Length): WaterFlowAttribute; + + /** + * Control layout direction of the WaterFlow. + * @since 9 + */ + layoutDirection(value: FlexDirection): WaterFlowAttribute; + + /** + * Called when the water flow begins to arrive. + * @since 9 + */ + onReachStart(event: () => void): WaterFlowAttribute; + + /** + * Called when the water flow reaches the end. + * @since 9 + */ + onReachEnd(event: () => void): WaterFlowAttribute; +} + +declare const WaterFlow: WaterFlowInterface; +declare const WaterFlowInstance: WaterFlowAttribute; diff --git a/api/@internal/component/ets/xcomponent.d.ts b/api/@internal/component/ets/xcomponent.d.ts index 522fc23bb96e0961b41f5adc36153b84c5006119..27b9e77e4f3e3a2b7d5d0d494873eea05c0571f6 100644 --- a/api/@internal/component/ets/xcomponent.d.ts +++ b/api/@internal/component/ets/xcomponent.d.ts @@ -33,13 +33,13 @@ declare class XComponentController { * Get the id of surface created by XComponent. * @since 9 */ - getXComponentSurfaceId(); + getXComponentSurfaceId(): string; /** * Get the context of native XComponent. * @since 8 */ - getXComponentContext(); + getXComponentContext(): Object; /** * Set the surface size created by XComponent. @@ -53,7 +53,7 @@ declare class XComponentController { setXComponentSurfaceSize(value: { surfaceWidth: number; surfaceHeight: number; - }); + }): void; } /** diff --git a/api/@ohos.WorkSchedulerExtensionAbility.d.ts b/api/@ohos.WorkSchedulerExtensionAbility.d.ts index df30bd831e426edec007243471ac505d27209e50..e84ee214c257927a1d5e2aa2b3af5e6167f671f4 100644 --- a/api/@ohos.WorkSchedulerExtensionAbility.d.ts +++ b/api/@ohos.WorkSchedulerExtensionAbility.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import workScheduler from "./@ohos.workScheduler"; +import workScheduler from "./@ohos.resourceschedule.workScheduler"; /** * Class of the work scheduler extension ability. diff --git a/api/@ohos.ability.ability.d.ts b/api/@ohos.ability.ability.d.ts index 44be58f12e8b9ef4cb8065dcefc71c68003f576b..dde29080261399f4c2f9b1ff815d44b17855456e 100755 --- a/api/@ohos.ability.ability.d.ts +++ b/api/@ohos.ability.ability.d.ts @@ -26,7 +26,7 @@ import { StartAbilityParameter as _StartAbilityParameter } from './ability/star * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore - * @StageModelOnly + * @FAModelOnly */ declare namespace ability { @@ -50,6 +50,7 @@ declare namespace ability { /** * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly */ export type DataAbilityOperation = _DataAbilityOperation @@ -57,24 +58,28 @@ declare namespace ability { * @name DataAbilityResult * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly */ export type DataAbilityResult = _DataAbilityResult /** * @since 9 * @syscap SystemCapability.Ability.AbilityBase + * @FAModelOnly */ export type AbilityResult = _AbilityResult /** * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly */ export type ConnectOptions = _ConnectOptions /** * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly */ export type StartAbilityParameter = _StartAbilityParameter } diff --git a/api/@ohos.ability.wantConstant.d.ts b/api/@ohos.ability.wantConstant.d.ts index 15ce6b7a38b7e0742efabde7e282d361b7686d59..9ad6e2e43a9cb602118252b46736f42557f94169 100644 --- a/api/@ohos.ability.wantConstant.d.ts +++ b/api/@ohos.ability.wantConstant.d.ts @@ -19,6 +19,8 @@ * @since 6 * @syscap SystemCapability.Ability.AbilityBase * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.wantConstant */ declare namespace wantConstant { /** diff --git a/api/@ohos.abilityAccessCtrl.d.ts b/api/@ohos.abilityAccessCtrl.d.ts index a8c7a3a08ec7f0037f93a8df44c47a3ffef57c30..23474f7e6ff67c939e779ee0c6a074513fe765d5 100644 --- a/api/@ohos.abilityAccessCtrl.d.ts +++ b/api/@ohos.abilityAccessCtrl.d.ts @@ -42,6 +42,14 @@ import { Permissions } from './permissions'; * @useinstead ohos.abilityAccessCtrl.AtManager#checkAccessToken */ verifyAccessToken(tokenID: number, permissionName: string): Promise; + + /** + * 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. Permissions type only support the valid permission name. + * @return Returns permission verify result. + * @since 9 + */ verifyAccessToken(tokenID: number, permissionName: Permissions): Promise; /** diff --git a/api/@ohos.accessibility.config.d.ts b/api/@ohos.accessibility.config.d.ts index 2dfac6d56a12e8b0f7d6f5389a8e05bf6d719822..690c702cff722a9bcc8a12bc1cba09c778ec90e4 100644 --- a/api/@ohos.accessibility.config.d.ts +++ b/api/@ohos.accessibility.config.d.ts @@ -77,6 +77,10 @@ declare namespace config { * Enable the accessibility extension ability. * @param name Indicates the accessibility extension name, in "bundleName/abilityName" format. * @param capability Indicates the ability. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Input parameter error. + * @throws { BusinessError } 9300001 - Invalid bundle name or ability name. + * @throws { BusinessError } 9300002 - Target ability already enabled. */ function enableAbility(name: string, capability: Array): Promise; function enableAbility(name: string, capability: Array, callback: AsyncCallback): void; @@ -84,23 +88,28 @@ declare namespace config { /** * Disable the accessibility extension ability. * @param name Indicates the accessibility extension name, in "bundleName/abilityName" format. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Input parameter error. + * @throws { BusinessError } 9300001 - Invalid bundle name or ability name. */ function disableAbility(name: string): Promise; function disableAbility(name: string, callback: AsyncCallback): void; /** * Register the listener that watches for changes in the enabled status of accessibility extensions. - * @param type Indicates the enableAbilityListsStateChanged type. + * @param type Indicates the type of event. * @param callback Indicates the listener. + * @throws { BusinessError } 401 - Input parameter error. */ - function on(type: 'enableAbilityListsStateChanged', callback: Callback): void; + function on(type: 'enabledAccessibilityExtensionListChange', callback: Callback): void; /** - * Deregister listener that watches for changes in the enabled status of accessibility extensions. - * @param type Indicates the enableAbilityListsStateChanged type. + * Unregister listener that watches for changes in the enabled status of accessibility extensions. + * @param type Indicates the type of event. * @param callback Indicates the listener. + * @throws { BusinessError } 401 - Input parameter error. */ - function off(type: 'enableAbilityListsStateChanged', callback?: Callback): void; + function off(type: 'enabledAccessibilityExtensionListChange', callback?: Callback): void; /** * Indicates setting, getting, and listening to changes in configuration. @@ -109,6 +118,8 @@ declare namespace config { /** * Setting configuration value. * @param value Indicates the value. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Input parameter error. */ set(value: T): Promise; set(value: T, callback: AsyncCallback): void; @@ -122,11 +133,12 @@ declare namespace config { /** * Register the listener to listen for configuration changes. * @param callback Indicates the listener. + * @throws { BusinessError } 401 - Input parameter error. */ on(callback: Callback): void; /** - * Deregister the listener to listen for configuration changes. + * Unregister the listener to listen for configuration changes. * @param callback Indicates the listener. */ off(callback?: Callback): void; diff --git a/api/@ohos.accessibility.d.ts b/api/@ohos.accessibility.d.ts index 50f45c02511d3221390c5f66ef819796005be0cf..8b5b372e0a6f710bb266f0a166a5ad5028833d2d 100644 --- a/api/@ohos.accessibility.d.ts +++ b/api/@ohos.accessibility.d.ts @@ -24,13 +24,19 @@ import { Callback } from './basic'; * @import basic,abilityInfo */ declare namespace accessibility { - /** * The type of the Ability app. + * @type { 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual' } * @syscap SystemCapability.BarrierFree.Accessibility.Core * @since 7 */ - type AbilityType = 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual'; + /** + * The type of the Ability app. + * @type { 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual' | 'all' } + * @syscap SystemCapability.BarrierFree.Accessibility.Core + * @since 9 + */ + type AbilityType = 'audible' | 'generic' | 'haptic' | 'spoken' | 'visual' | 'all'; /** * The action that the ability can execute. @@ -98,7 +104,7 @@ declare namespace accessibility { * @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; @@ -108,7 +114,7 @@ declare namespace accessibility { * @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; @@ -119,24 +125,26 @@ declare namespace accessibility { * @param stateType The state of the accessibility ability. {@code AbilityState} eg.installed * @syscap SystemCapability.BarrierFree.Accessibility.Core * @return Returns the list of abilityInfos. - */ + * @deprecated since 9 + * @useinstead ohos.accessibility#getAccessibilityExtensionList + */ 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 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: 'all', stateType: AbilityState, - callback: AsyncCallback>): void; - function getAbilityLists(abilityType: 'all', - stateType: AbilityState): Promise>; + * @throws { BusinessError } 401 - Input parameter error. + */ + function getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState): Promise>; + function getAccessibilityExtensionList(abilityType: AbilityType, stateType: AbilityState, callback: AsyncCallback>): void; /** * Send accessibility Event. @@ -145,46 +153,64 @@ declare namespace accessibility { * @param callback Asynchronous callback interface. * @syscap SystemCapability.BarrierFree.Accessibility.Core * @return Returns {@code true} if success ; returns {@code false} otherwise. + * @deprecated since 9 + * @useinstead ohos.accessibility#sendAccessibilityEvent */ function sendEvent(event: EventInfo, callback: AsyncCallback): void; function sendEvent(event: EventInfo): Promise; /** - * Register the observe of the accessibility state changed. + * Send accessibility event. + * @since 9 + * @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. + * @throws { BusinessError } 401 - Input parameter error. + */ + function sendAccessibilityEvent(event: EventInfo, callback: AsyncCallback): void; + function sendAccessibilityEvent(event: EventInfo): Promise; + + /** + * Register the observer 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. + * @throws { BusinessError } 401 - Input parameter error. */ function on(type: 'accessibilityStateChange', callback: Callback): void; /** - * Register the observe of the touchGuide state changed. + * Register the observer 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. + * @throws { BusinessError } 401 - Input parameter error. */ function on(type: 'touchGuideStateChange', callback: Callback): void; /** - * Deregister the observe of the accessibility state changed. + * Unregister the observer 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. + * @return Returns {@code true} if the Unregister is success ; returns {@code false} otherwise. + * @throws { BusinessError } 401 - Input parameter error. */ function off(type: 'accessibilityStateChange', callback?: Callback): void; /** - * Deregister the observe of the touchGuide state changed. + * Unregister the observer 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. + * @return Returns {@code true} if the Unregister is success ; returns {@code false} otherwise. + * @throws { BusinessError } 401 - Input parameter error. */ function off(type: 'touchGuideStateChange', callback?: Callback): void; @@ -212,19 +238,26 @@ declare namespace accessibility { style: CaptionsStyle; /** - * Register the observe of the enable state. + * Register the observer of the enable state. + * @throws { BusinessError } 401 - Input parameter error. */ on(type: 'enableChange', callback: Callback): void; + /** * Register the observer of the style. + * @throws { BusinessError } 401 - Input parameter error. */ on(type: 'styleChange', callback: Callback): void; + /** - * Deregister the observe of the enable state. + * Unregister the observer of the enable state. + * @throws { BusinessError } 401 - Input parameter error. */ off(type: 'enableChange', callback?: Callback): void; + /** - * Deregister the observer of the style. + * Unregister the observer of the style. + * @throws { BusinessError } 401 - Input parameter error. */ off(type: 'styleChange', callback?: Callback): void; } diff --git a/api/@ohos.account.appAccount.d.ts b/api/@ohos.account.appAccount.d.ts index c1c808ad92bd76176f2a1a85d9a7947be5cdde77..2d4f53cb3673bc15786d47426c787e0249d0b214 100644 --- a/api/@ohos.account.appAccount.d.ts +++ b/api/@ohos.account.appAccount.d.ts @@ -65,8 +65,8 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name or options. - * @throws {BusinessError} 12300008 - the account indicated by name already exist. - * @throws {BusinessError} 12300011 - the account number has reached the upper limit. + * @throws {BusinessError} 12300004 - the account indicated by name already exist. + * @throws {BusinessError} 12300007 - the account number has reached the upper limit. * @since 9 */ createAccount(name: string, callback: AsyncCallback): void; @@ -95,8 +95,10 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid owner or options. - * @throws {BusinessError} 12300011 - the account number has reached the upper limit. - * @throws {BusinessError} 12400002 - the account authenticator service does not exist. + * @throws {BusinessError} 12300007 - the account number has reached the upper limit. + * @throws {BusinessError} 12300010 - account service busy. + * @throws {BusinessError} 12300113 - the account authenticator service does not exist. + * @throws {BusinessError} 12300114 - authenticator service exception. * @since 9 */ createAccountImplicitly(owner: string, callback: AuthCallback): void; @@ -166,7 +168,7 @@ declare namespace appAccount { * @returns void. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid name or bundlename. + * @throws {BusinessError} 12300002 - invalid name or bundle name. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @throws {BusinessError} 12400001 - the application indicated by bundlename does not exist. * @since 9 @@ -182,9 +184,8 @@ declare namespace appAccount { * @returns void. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid name or bundlename. + * @throws {BusinessError} 12300002 - invalid name or bundle name. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12400001 - the application indicated by bundlename does not exist. * @since 9 */ checkAppAccess(name: string, bundleName: string, callback: AsyncCallback): void; @@ -197,7 +198,7 @@ declare namespace appAccount { * through the distributed networking. On the connected devices, you can call this method to check * whether application data can be synchronized. *

- * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @param name Indicates the name of the application account. * @returns Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. * @since 7 @@ -214,7 +215,7 @@ declare namespace appAccount { * through the distributed networking. On the connected devices, you can call this method to check * whether application data can be synchronized. *

- * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @param name Indicates the name of the application account. * @returns Returns {@code true} if application data synchronization is allowed; returns {@code false} otherwise. * @throws {BusinessError} 201 - permission denied. @@ -249,7 +250,7 @@ declare namespace appAccount { * @returns void. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid name or credentialType. + * @throws {BusinessError} 12300002 - invalid name, credentialType or credential. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. * @since 9 */ @@ -267,6 +268,7 @@ declare namespace appAccount { * @returns void. * @since 7 * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#setCustomData */ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback): void; setAccountExtraInfo(name: string, extraInfo: string): Promise; @@ -275,7 +277,7 @@ declare namespace appAccount { * 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 + * through the distributed networking. On the connected 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. @@ -286,7 +288,7 @@ declare namespace appAccount { * Application data that can be synchronized: application account name, token, * and data associated with this application account *

- * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @param name Indicates the name of the application account. * @param isEnable Specifies whether to allow application data synchronization. * @returns void. @@ -301,7 +303,7 @@ declare namespace appAccount { * Sets whether a specified application account enables 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 + * through the distributed networking. On the connected devices, you can call this method to set whether to * enable cross-device data synchronization. If synchronization is enabled, application data can be synchronized * among these devices in the event of any changes related to the application account. * If synchronization is not enabled, the application data is stored only on the local device. @@ -312,7 +314,7 @@ declare namespace appAccount { * Application data that can be synchronized: application account name, token, * and data associated with this application account *

- * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @param name Indicates the name of the application account. * @param isEnabled Specifies whether to enable application data synchronization. * @returns void. @@ -349,7 +351,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, key or value. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12400008 - the number of customized data has reached the upper limit. + * @throws {BusinessError} 12400003 - the number of customized data has reached the upper limit. * @since 9 */ setCustomData(name: string, key: string, value: string, callback: AsyncCallback): void; @@ -364,7 +366,7 @@ declare namespace appAccount { *

  • Accounts of third-party applications. To obtain such information, * your application must have gained authorization from the third-party applications.
  • * - * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS * @returns Returns a list of application accounts. * @since 7 * @deprecated since 9 @@ -382,7 +384,7 @@ declare namespace appAccount { *
  • Accounts of third-party applications. To obtain such information, * your application must have gained authorization from the third-party applications.
  • * - * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS * @returns Returns a list of application accounts. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -401,7 +403,7 @@ declare namespace appAccount { *
  • Accounts of third-party applications. To obtain such information, * your application must have gained authorization from the third-party applications.
  • * - * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS * @param owner Indicates the account owner of your application or third-party applications. * @returns Returns a list of application accounts. * @since 7 @@ -420,14 +422,14 @@ declare namespace appAccount { *
  • Accounts of third-party applications. To obtain such information, * your application must have gained authorization from the third-party applications.
  • * - * @permission ohos.permission.GET_ALL_APP_ACCOUNTS. + * @permission ohos.permission.GET_ALL_APP_ACCOUNTS * @param owner Indicates the account owner of your application or third-party applications. * @returns Returns a list of application accounts. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid owner. - * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12400001 - the application indicated by bundle name does not exist. * @since 9 */ getAccountsByOwner(owner: string, callback: AsyncCallback>): void; @@ -454,7 +456,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name or credentialType. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12300102 - credential does not exist. * @since 9 */ getCredential(name: string, credentialType: string, callback: AsyncCallback): void; @@ -467,6 +469,7 @@ declare namespace appAccount { * for example, if the account does not exist. * @since 7 * @deprecated since 9 + * @useinstead appAccount.AppAccountManager#getCustomData */ getAccountExtraInfo(name: string, callback: AsyncCallback): void; getAccountExtraInfo(name: string): Promise; @@ -492,7 +495,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name or key. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12400009 - the customData does not exist. + * @throws {BusinessError} 12400002 - the customData does not exist. * @since 9 */ getCustomData(name: string, key: string, callback: AsyncCallback): void; @@ -507,6 +510,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name or key. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12400002 - the customData does not exist. * @since 9 */ getCustomDataSync(name: string, key: string): string; @@ -536,8 +540,8 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid type or owners. - * @throws {BusinessError} 12300003 - the account indicated by owners dose not exist. - * @throws {BusinessError} 12300005 - the listener has been registered. + * @throws {BusinessError} 12300011 - the callback has been registered. + * @throws {BusinessError} 12400001 - the application indicated by owner does not exist. * @since 9 */ on(type: 'accountChange', owners: Array, callback: Callback>): void; @@ -557,7 +561,7 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid type. - * @throws {BusinessError} 12300005 - the listener has been registered. + * @throws {BusinessError} 12300012 - the callback has not been registered. * @since 9 */ off(type: 'accountChange', callback?: Callback>): void; @@ -588,10 +592,9 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, owner, authType or options. * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. - * @throws {BusinessError} 12300016 - authentication timeout. - * @throws {BusinessError} 12300017 - authentication service is busy. - * @throws {BusinessError} 12300018 - authentication service is locked. - * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @throws {BusinessError} 12300010 - account service busy. + * @throws {BusinessError} 12300113 - the account authenticator service does not exist. + * @throws {BusinessError} 12300114 - authenticator service exception. * @since 9 */ auth(name: string, owner: string, authType: string, callback: AuthCallback): void; @@ -620,8 +623,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, owner or authType. * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @throws {BusinessError} 12300107 - the authType is not found. * @since 9 */ getAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback): void; @@ -654,9 +656,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, owner, authType or token. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300019 - credential does not exist. - * @throws {BusinessError} 12400007 - the number of token has reached the upper limit. + * @throws {BusinessError} 12400004 - the number of token has reached the upper limit. * @since 9 */ setAuthToken(name: string, authType: string, token: string, callback: AsyncCallback): void; @@ -691,8 +691,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, owner, authType or token. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12300107 - the authType is not found. * @since 9 */ deleteAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback): void; @@ -727,8 +726,9 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, authType or bundleName. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12300107 - the authType is not found. + * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @throws {BusinessError} 12400005 - the size of authorization list reaches the upper limit. * @since 9 */ setAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback): void; @@ -761,8 +761,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, authType or bundleName. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12300107 - the authType is not found. * @since 9 */ checkAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback): void; @@ -795,7 +794,7 @@ declare namespace appAccount { getAllAuthTokens(name: string, owner: string): Promise>; /** - * Gets the open authorization list with a specified authentication type for a paticular application account. + * Gets the open authorization list with a specified authentication type for a particular application account. *

    * Only the owner of the application account has the permission to call this method. * @param name Indicates the account name of your application. @@ -809,7 +808,7 @@ declare namespace appAccount { getOAuthList(name: string, authType: string): Promise>; /** - * Gets the open authorization list with a specified authentication type for a paticular application account. + * Gets the open authorization list with a specified authentication type for a particular application account. *

    * Only the owner of the application account has the permission to call this method. * @param name Indicates the account name of your application. @@ -819,8 +818,7 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name or authType. * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300019 - credential does not exist. + * @throws {BusinessError} 12300107 - the authType is not found. * @since 9 */ getAuthList(name: string, authType: string, callback: AsyncCallback>): void; @@ -847,7 +845,8 @@ declare namespace appAccount { * @returns Returns the authenticator callback related to the session id. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12400005 - the session indicated by sessionId does not exist. + * @throws {BusinessError} 12300002 - invalid session id. + * @throws {BusinessError} 12300108 - the session indicated by sessionId does not exist. * @since 9 */ getAuthCallback(sessionId: string, callback: AsyncCallback): void; @@ -871,23 +870,25 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid owner. - * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. + * @throws {BusinessError} 12300113 - the account authenticator service does not exist. * @since 9 */ queryAuthenticatorInfo(owner: string, callback: AsyncCallback): void; queryAuthenticatorInfo(owner: string): Promise; /** - * Checks whether a paticular account has all specified labels. + * Checks whether a particular account has all specified labels. * @param name Indicates the account name. * @param owner Indicates the account owner. * @param labels Indicates an array of labels to check. * @returns boolean * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid name or owner. + * @throws {BusinessError} 12300002 - invalid name, owner or labels. * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. - * @throws {BusinessError} 12400001 - the application indicated by name does not exist. + * @throws {BusinessError} 12300010 - account service busy. + * @throws {BusinessError} 12300113 - the account authenticator service does not exist. + * @throws {BusinessError} 12300114 - authenticator service exception. * @since 9 */ checkAccountLabels(name: string, owner: string, labels: Array, callback: AsyncCallback): void; @@ -901,9 +902,9 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name or credentialType. - * @throws {BusinessError} 12300019 - credential does not exist. - * @throws {BusinessError} 12400001 - the application indicated by name does not exist. - * since 9 + * @throws {BusinessError} 12300003 - the account indicated by name dose not exist. + * @throws {BusinessError} 12300102 - credential does not exist. + * @since 9 */ deleteCredential(name: string, credentialType: string, callback: AsyncCallback): void; deleteCredential(name: string, credentialType: string): Promise; @@ -915,6 +916,8 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid options. + * @throws {BusinessError} 12300010 - account service busy. + * @throws {BusinessError} 12300114 - authenticator service exception. * @since 9 */ selectAccountsByOptions(options: SelectAccountsOptions, callback: AsyncCallback>): void; @@ -931,8 +934,9 @@ declare namespace appAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid name, owner or options. * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. - * @throws {BusinessError} 12400001 - the application indicated by name does not exist. - * @throws {BusinessError} 12400002 - he account authenticator service does not exist. + * @throws {BusinessError} 12300010 - account service busy. + * @throws {BusinessError} 12300113 - the account authenticator service does not exist. + * @throws {BusinessError} 12300114 - authenticator service exception. * @since 9 */ verifyCredential(name: string, owner: string, callback: AuthCallback): void; @@ -949,8 +953,9 @@ declare namespace appAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid owner or options. - * @throws {BusinessError} 12300003 - the account indicated by owner dose not exist. - * @throws {BusinessError} 12400002 - the account authenticator service does not exist. + * @throws {BusinessError} 12300010 - account service busy. + * @throws {BusinessError} 12300113 - the account authenticator service does not exist. + * @throws {BusinessError} 12300114 - authenticator service exception. * @since 9 */ setAuthenticatorProperties(owner: string, callback: AuthCallback): void; @@ -1063,7 +1068,7 @@ declare namespace appAccount { */ interface AuthResult { /** - * The account infomation. + * The account information. * @since 9 */ account?: AppAccountInfo; @@ -1154,7 +1159,7 @@ declare namespace appAccount { */ interface VerifyCredentialOptions { /** - * The credentail type to be verified. + * The credential type to be verified. * @since 9 */ credentialType?: string; @@ -1281,7 +1286,7 @@ declare namespace appAccount { KEY_ACTION = "action", /** - * Indicates the key of authentiaction type. + * Indicates the key of authentication type. * * @since 8 */ @@ -1441,6 +1446,8 @@ declare namespace appAccount { * @param callback Indicates the authenticator callback. * @returns void. * @since 8 + * @deprecated since 9 + * @useinstead appAccount.Authenticator#createAccountImplicitly */ addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; @@ -1462,6 +1469,8 @@ declare namespace appAccount { * @param callback Indicates the authenticator callback. * @returns void. * @since 8 + * @deprecated since 9 + * @useinstead appAccount.Authenticator#auth */ authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; diff --git a/api/@ohos.account.distributedAccount.d.ts b/api/@ohos.account.distributedAccount.d.ts index 3e3b41439a0e946fb2ed98c435a39123283fd218..c5deff6f2bd92be14a5bd39595805bc29fc8b4bb 100644 --- a/api/@ohos.account.distributedAccount.d.ts +++ b/api/@ohos.account.distributedAccount.d.ts @@ -51,7 +51,7 @@ declare namespace distributedAccount { /** * Gets the distributed information of the current OS account. - * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS or ohos.permission.GET_DISTRIBUTED_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC. + * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS or ohos.permission.GET_DISTRIBUTED_ACCOUNTS or ohos.permission.DISTRIBUTED_DATASYNC * @returns The distributed information of the current OS account. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -63,7 +63,7 @@ declare namespace distributedAccount { /** * Updates the distributed information of the OS account. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param accountInfo Indicates the information of the OS account used for a distributed system. * @returns void * @since 7 @@ -75,13 +75,14 @@ declare namespace distributedAccount { /** * Sets the distributed information of the OS account. - * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS. + * @permission ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS * @param accountInfo Indicates the information of the OS account used for a distributed system. * @returns void * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid accountInfo. + * @throws {BusinessError} 12300003 - the account indicated by accountInfo dose not exist. * @since 9 */ setOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback): void; diff --git a/api/@ohos.account.osAccount.d.ts b/api/@ohos.account.osAccount.d.ts index 92a81d4b44d572743e76639447886445cdae8e48..c9ab2e19017cb3e0f8081f5fc5599c62abc1c9f1 100644 --- a/api/@ohos.account.osAccount.d.ts +++ b/api/@ohos.account.osAccount.d.ts @@ -44,7 +44,7 @@ declare namespace osAccount { * to run in the foreground. Then, the OS account originally running in the foreground will be * switched to the background. *

    - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION * @param localId Indicates the local ID of the OS account. * @returns void. * @throws {BusinessError} 201 - permission denied. @@ -52,8 +52,8 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12300003 - the account indicated by localId has been activated. - * @throws {BusinessError} 12300010 - account service is busy. + * @throws {BusinessError} 12300008 - the localId indicates restricted account. + * @throws {BusinessError} 12300009 - the account indicated by localId has been activated. * @systemapi Hide this for inner system use. * @since 7 */ @@ -94,7 +94,7 @@ declare namespace osAccount { /** * Checks whether an OS account is activated based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns void * @throws {BusinessError} 201 - permission denied. @@ -109,7 +109,7 @@ declare namespace osAccount { /** * Checks whether a constraint has been enabled for an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @param constraint Indicates the constraint to check. The value can be: *
      @@ -132,7 +132,7 @@ declare namespace osAccount { /** * Checks whether a constraint has been enabled for an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @param constraint Indicates the constraint to check. The value can be: *
        @@ -151,7 +151,6 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId or constraint. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12300004 - the localId indicates restricted account. * @since 9 */ checkConstraintEnabled(localId: number, constraint: string, callback: AsyncCallback): void; @@ -179,7 +178,7 @@ declare namespace osAccount { /** * Checks whether an OS account has been verified based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns Returns {@code true} if the OS account has been verified successfully; * returns {@code false} otherwise. @@ -194,7 +193,7 @@ declare namespace osAccount { /** * Checks whether an OS account has been verified based on its ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns Returns {@code true} if the OS account has been verified successfully; * returns {@code false} otherwise. @@ -211,7 +210,7 @@ declare namespace osAccount { /** * Removes an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns void. * @throws {BusinessError} 201 - permission denied. @@ -219,7 +218,7 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12300004 - the localId indicates restricted account. + * @throws {BusinessError} 12300008 - the localId indicates restricted account. * @systemapi Hide this for inner system use. * @since 7 */ @@ -228,7 +227,7 @@ declare namespace osAccount { /** * Sets constraints for an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @param constraints Indicates the constraints to set for the OS account. The value can be: *
          @@ -247,7 +246,7 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId or constraints. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12300004 - the localId indicates restricted account. + * @throws {BusinessError} 12300008 - the localId indicates restricted account. * @systemapi Hide this for inner system use. * @since 7 */ @@ -257,7 +256,7 @@ declare namespace osAccount { /** * Sets the local name for an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @param localName Indicates the local name to set for the OS account. * @returns void. @@ -266,7 +265,7 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId or localName. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12300004 - the localId indicates restricted account. + * @throws {BusinessError} 12300008 - the localId indicates restricted account. * @systemapi Hide this for inner system use. * @since 7 */ @@ -275,7 +274,7 @@ declare namespace osAccount { /** * Obtains the number of all OS accounts created on a device. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns the number of created OS accounts. * @since 7 * @deprecated since 9 @@ -286,7 +285,7 @@ declare namespace osAccount { /** * Obtains the number of all OS accounts created on a device. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns the number of created OS accounts. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -341,7 +340,7 @@ declare namespace osAccount { /** * Queries the local ID of an OS account which is bound to the specified domain account - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param domainInfo Indicates the domain account info. * @returns Returns the local ID of the OS account. * @since 8 @@ -354,7 +353,7 @@ declare namespace osAccount { /** * Queries the ID of an account which is bound to the specified domain account * - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param domainInfo Indicates the domain account info. * @returns Returns the local ID of the OS account. * @throws {BusinessError} 201 - permission denied. @@ -379,7 +378,7 @@ declare namespace osAccount { /** * Obtains all constraints of an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns Returns a list of constraints. * @since 7 @@ -391,7 +390,7 @@ declare namespace osAccount { /** * Obtains all constraints of an account based on its ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns Returns a list of constraints. * @throws {BusinessError} 201 - permission denied. @@ -399,7 +398,6 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. - * @throws {BusinessError} 12300004 - the localId indicates restricted account. * @since 9 */ getOsAccountConstraints(localId: number, callback: AsyncCallback>): void; @@ -407,7 +405,7 @@ declare namespace osAccount { /** * Queries the list of all the OS accounts that have been created in the system. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns a list of OS accounts. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -440,7 +438,7 @@ declare namespace osAccount { /** * Creates an OS account using the local name and account type. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localName Indicates the local name of the OS account to create. * @param type Indicates the type of the OS account to create. * {@link OsAccountType} specifies the account types available in the system. @@ -449,7 +447,9 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localName. - * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300005 - multi-user not supported. + * @throws {BusinessError} 12300006 - unsupported account type. + * @throws {BusinessError} 12300007 - the number of account reaches the upper limit. * @systemapi Hide this for inner system use. * @since 7 */ @@ -458,7 +458,7 @@ declare namespace osAccount { /** * Creates an OS account using the account type and domain account info. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param type Indicates the type of the OS account to create. * {@link OsAccountType} specifies the account types available in the system. * @param domainInfo Indicates the domain account info. @@ -467,6 +467,9 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid type or domainInfo. + * @throws {BusinessError} 12300005 - multi-user not supported. + * @throws {BusinessError} 12300006 - unsupported account type. + * @throws {BusinessError} 12300007 - the number of account reaches the upper limit. * @systemapi Hide this for inner system use. * @since 8 */ @@ -475,7 +478,7 @@ declare namespace osAccount { /** * Queries information about the current OS account. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns information about the current OS account; returns {@code null} if the query fails. * @since 7 * @deprecated since 9 @@ -486,7 +489,7 @@ declare namespace osAccount { /** * Gets information about the current OS account. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns information about the current OS account; returns {@code null} if the query fails. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -499,7 +502,7 @@ declare namespace osAccount { /** * Queries OS account information based on the local ID. * - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION * @param localId Indicates the local ID of the OS account. * @returns Returns the OS account information; returns {@code null} if the query fails. * @throws {BusinessError} 201 - permission denied. @@ -539,7 +542,7 @@ declare namespace osAccount { * 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. + * through the distributed networking. On the connected 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. *

          @@ -556,11 +559,11 @@ declare namespace osAccount { * Queries 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. + * through the distributed networking. On the connected 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. *

          - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.DISTRIBUTED_DATASYNC or ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns the DVID if obtained; returns an empty string if no OHOS account has logged in. * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -572,7 +575,7 @@ declare namespace osAccount { /** * Obtains the profile photo of an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @returns Returns the profile photo if obtained; * returns {@code null} if the profile photo fails to be obtained. @@ -589,7 +592,7 @@ declare namespace osAccount { /** * Sets the profile photo for an OS account based on its local ID. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @param localId Indicates the local ID of the OS account. * @param photo Indicates the profile photo to set for the OS account. * @returns void. @@ -598,6 +601,7 @@ declare namespace osAccount { * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid localId or photo. * @throws {BusinessError} 12300003 - the account indicated by localId dose not exist. + * @throws {BusinessError} 12300008 - the localId indicates restricted account. * @systemapi Hide this for inner system use. * @since 7 */ @@ -621,6 +625,8 @@ declare namespace osAccount { * @returns localId. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. + * @throws {BusinessError} 12300002 - invalid serialNumber. + * @throws {BusinessError} 12300003 - the account indicated by serialNumber dose not exist. * @since 9 */ queryOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback): void; @@ -662,7 +668,8 @@ declare namespace osAccount { * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300005 - the listener has been registered. + * @throws {BusinessError} 12300002 - invalid type or name. + * @throws {BusinessError} 12300011 - the callback has been registered. * @systemapi Hide this for inner system use. * @since 7 */ @@ -677,7 +684,8 @@ declare namespace osAccount { * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300006 - the listener has not been registered. + * @throws {BusinessError} 12300002 - invalid type or name. + * @throws {BusinessError} 12300012 - the callback has not been registered. * @systemapi Hide this for inner system use. * @since 7 */ @@ -698,7 +706,7 @@ declare namespace osAccount { /** * Check whether current process belongs to the main account. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns {@code true} if current process belongs to the main os account; * returns {@code false} otherwise. * @throws {BusinessError} 201 - permission denied. @@ -712,7 +720,7 @@ declare namespace osAccount { /** * Query the constraint source type list of the OS account. - * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS. + * @permission ohos.permission.MANAGE_LOCAL_ACCOUNTS * @returns Returns the constraint source type infos of the os account; * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. @@ -882,8 +890,6 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid authType or authTrustLevel. - * @throws {BusinessError} 12300014 - the authTrustLevel is not supported on current device - * @throws {BusinessError} 12300015 - the authType is not supported on current device. * @systemapi Hide this for inner system use. * @since 8 */ @@ -931,12 +937,12 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid challenge, authType or authTrustLevel. - * @throws {BusinessError} 12300014 - the authTrustLevel is not supported on current device - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300016 - authentication timeout. - * @throws {BusinessError} 12300017 - authentication service is busy. - * @throws {BusinessError} 12300018 - authentication service is locked. - * @throws {BusinessError} 12300019 - the credential does not exist. + * @throws {BusinessError} 12300101 - token is invalid. + * @throws {BusinessError} 12300105 - unsupported authTrustLevel. + * @throws {BusinessError} 12300106 - unsupported authType. + * @throws {BusinessError} 12300110 - authentication is locked. + * @throws {BusinessError} 12300111 - authentication timeout. + * @throws {BusinessError} 12300112 - authentication service is busy. * @systemapi Hide this for inner system use. * @since 8 */ @@ -955,13 +961,12 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid userId, challenge, authType or authTrustLevel. - * @throws {BusinessError} 12300003 - the account indicated by userId dose not exist. - * @throws {BusinessError} 12300014 - the authTrustLevel is not supported on current device - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300016 - authentication timeout. - * @throws {BusinessError} 12300017 - authentication service is busy. - * @throws {BusinessError} 12300018 - authentication service is locked. - * @throws {BusinessError} 12300019 - the credential does not exist. + * @throws {BusinessError} 12300101 - token is invalid. + * @throws {BusinessError} 12300105 - unsupported authTrustLevel. + * @throws {BusinessError} 12300106 - unsupported authType. + * @throws {BusinessError} 12300110 - authentication is locked. + * @throws {BusinessError} 12300111 - authentication timeout. + * @throws {BusinessError} 12300112 - authentication service is busy. * @systemapi Hide this for inner system use. * @since 8 */ @@ -974,7 +979,7 @@ declare namespace osAccount { * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid contexId. + * @throws {BusinessError} 12300002 - invalid contextId. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1003,7 +1008,7 @@ declare namespace osAccount { * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300007 - PIN inputer has been registered. + * @throws {BusinessError} 12300103 - the credential inputer has been registered. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1054,7 +1059,7 @@ declare namespace osAccount { *

          * Add user credential information, pass in credential addition method and credential information * (credential type, subclass, if adding user's non password credentials, pass in password authentication token), - * and get the result / acquireinfo callback. + * and get the result / acquireInfo callback. * @permission ohos.permission.MANAGE_USER_IDM * @param credentialInfo Indicates the credential information. * @param callback Indicates the callback to get results and acquireInfo. @@ -1062,6 +1067,8 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid credentialInfo. + * @throws {BusinessError} 12300101 - token is invalid. + * @throws {BusinessError} 12300106 - unsupported authType. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1076,6 +1083,8 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid credentialInfo. + * @throws {BusinessError} 12300101 - token is invalid. + * @throws {BusinessError} 12300106 - unsupported authType. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1112,7 +1121,7 @@ declare namespace osAccount { * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid token. + * @throws {BusinessError} 12300101 - token is invalid. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1127,7 +1136,9 @@ declare namespace osAccount { * @throws {BusinessError} 201 - permission denied. * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. - * @throws {BusinessError} 12300002 - invalid credentialId or token. + * @throws {BusinessError} 12300002 - invalid credentialId. + * @throws {BusinessError} 12300101 - token is invalid. + * @throws {BusinessError} 12300102 - credential not found. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1143,11 +1154,7 @@ declare namespace osAccount { * @throws {BusinessError} 401 - the parameter check failed. * @throws {BusinessError} 12300001 - system service exception. * @throws {BusinessError} 12300002 - invalid authType. - * @throws {BusinessError} 12300015 - the authType is not supported on current device. - * @throws {BusinessError} 12300016 - authentication timeout. - * @throws {BusinessError} 12300017 - authentication service is busy. - * @throws {BusinessError} 12300018 - authentication service is locked. - * @throws {BusinessError} 12300019 - the credential does not exist. + * @throws {BusinessError} 12300102 - credential not found. * @systemapi Hide this for inner system use. * @since 8 */ @@ -1207,9 +1214,9 @@ declare namespace osAccount { * The authentication result code is returned through the callback. * @param result Indicates the authentication result code. * @param extraInfo Indicates 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. + * 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. * @systemapi Hide this for inner system use. * @since 8 */ diff --git a/api/@ohos.app.ability.Ability.d.ts b/api/@ohos.app.ability.Ability.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a29250be373eb853fd6f75ee6b44349d42bc323b --- /dev/null +++ b/api/@ohos.app.ability.Ability.d.ts @@ -0,0 +1,56 @@ +/* + * 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 AbilityConstant from "./@ohos.app.ability.AbilityConstant"; +import { Configuration } from './@ohos.app.ability.Configuration'; + +/** + * The class of an ability. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export default class Ability { + /** + * Called when the system configuration is updated. + * @param { Configuration } newConfig - Indicates the updated configuration. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onConfigurationUpdate(newConfig: Configuration): 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. + * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory + * usage status. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onMemoryLevel(level: AbilityConstant.MemoryLevel): void; + + /** + * Called back when an ability prepares to save. + * @param reason state type when save. + * @param wantParam Indicates the want parameter. + * @return 0 if ability agrees to save data successfully, otherwise errcode. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult; +} diff --git a/api/@ohos.app.ability.AbilityConstant.d.ts b/api/@ohos.app.ability.AbilityConstant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3709949ca5f5facb5e085ff2d87713a3e2367d57 --- /dev/null +++ b/api/@ohos.app.ability.AbilityConstant.d.ts @@ -0,0 +1,147 @@ +/* + * 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. + * @namespace AbilityConstant + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ +declare namespace AbilityConstant { + /** + * Interface of launch param. + * @typedef LaunchParam + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export interface LaunchParam { + /** + * Indicates launch reason. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + launchReason: LaunchReason; + + /** + * Indicates last exit reason. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + lastExitReason: LastExitReason; + } + + /** + * Type of launch reason. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum LaunchReason { + UNKNOWN = 0, + START_ABILITY = 1, + CALL = 2, + CONTINUATION = 3, + APP_RECOVERY = 4, + } + + /** + * Type of last exit reason. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum LastExitReason { + UNKNOWN = 0, + ABILITY_NOT_RESPONDING = 1, + NORMAL = 2, + } + + /** + * Type of onContinue result. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum OnContinueResult { + AGREE = 0, + REJECT = 1, + MISMATCH = 2, + } + + /** + * Type of memory level. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum MemoryLevel { + MEMORY_LEVEL_MODERATE = 0, + MEMORY_LEVEL_LOW = 1, + MEMORY_LEVEL_CRITICAL = 2, + } + + /** + * Type of window mode. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum WindowMode { + WINDOW_MODE_UNDEFINED = 0, + WINDOW_MODE_FULLSCREEN = 1, + WINDOW_MODE_SPLIT_PRIMARY = 100, + WINDOW_MODE_SPLIT_SECONDARY = 101, + WINDOW_MODE_FLOATING = 102, + } + + /** + * Type of onSave result. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum OnSaveResult { + ALL_AGREE = 0, + CONTINUATION_REJECT = 1, + CONTINUATION_MISMATCH = 2, + RECOVERY_AGREE = 3, + RECOVERY_REJECT = 4, + ALL_REJECT, + } + + /** + * Type of save state. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum StateType { + CONTINUATION = 0, + APP_RECOVERY = 1, + } +} + +export default AbilityConstant; diff --git a/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f62e30feaf347dd772f8877d8ca279bd9e31f95 --- /dev/null +++ b/api/@ohos.app.ability.AbilityLifecycleCallback.d.ts @@ -0,0 +1,111 @@ +/* + * 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 UIAbility from "./@ohos.app.ability.UIAbility"; +import dataAbility from "./@ohos.data.dataAbility"; +import window from './@ohos.window'; + +/** + * The ability lifecycle callback. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export default class AbilityLifecycleCallback { + /** + * Called back when an ability is started for initialization. + * @param { Ability } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onAbilityCreate(ability: UIAbility): void; + + /** + * Called back when a window stage is created. + * @param { Ability } ability - Indicates the ability to register for listening. + * @param { window.WindowStage } windowStage - window stage to create + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void; + + /** + * Called back when a window stage is actived. + * @param { Ability } ability - Indicates the ability to register for listening. + * @param { window.WindowStage } windowStage - window stage to active + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageActive(ability: UIAbility, windowStage: window.WindowStage): void; + + /** + * Called back when a window stage is inactived. + * @param { Ability } ability - Indicates the ability to register for listening. + * @param { window.WindowStage } windowStage - window stage to inactive + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageInactive(ability: UIAbility, windowStage: window.WindowStage): void; + + /** + * Called back when a window stage is destroyed. + * @param { Ability } ability - Indicates the ability to register for listening. + * @param { window.WindowStage } windowStage - window stage to destroy + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void; + + /** + * Called back when an ability is destroyed. + * @param { Ability } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onAbilityDestroy(ability: UIAbility): void; + + /** + * Called back when the state of an ability changes to foreground. + * @param { Ability } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onAbilityForeground(ability: UIAbility): void; + + /** + * Called back when the state of an ability changes to background. + * @param { Ability } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onAbilityBackground(ability: UIAbility): void; + + /** + * Called back when an ability prepares to continue. + * @param { Ability } ability - Indicates the ability to register for listening. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onAbilityContinue(ability: UIAbility): void; +} \ No newline at end of file diff --git a/api/@ohos.app.ability.AbilityStage.d.ts b/api/@ohos.app.ability.AbilityStage.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8aa0201a3f3c1ad0e0d2e394e8970ecccb3bbcef --- /dev/null +++ b/api/@ohos.app.ability.AbilityStage.d.ts @@ -0,0 +1,75 @@ +/* + * 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 AbilityConstant from "./@ohos.app.ability.AbilityConstant"; +import AbilityStageContext from "./application/AbilityStageContext"; +import Want from './@ohos.app.ability.Want'; +import { Configuration } from './@ohos.app.ability.Configuration'; + +/** + * The class of an ability stage. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ +export default class AbilityStage { + /** + * Indicates configuration information about context. + * @type { AbilityStageContext } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + context: AbilityStageContext; + + /** + * Called back when an ability stage is started for initialization. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + onCreate(): void; + + /** + * Called back when start specified ability. + * @param { Want } want - Indicates the want info of startd ability. + * @return { string } 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. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + onAcceptWant(want: Want): string; + + /** + * Called when the system configuration is updated. + * @param { Configuration } newConfig - Indicates the updated configuration. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + onConfigurationUpdate(newConfig: Configuration): 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. + * @param { AbilityConstant.MemoryLevel } level - Indicates the memory trim level, which shows the current memory usage status. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + onMemoryLevel(level: AbilityConstant.MemoryLevel): void; +} diff --git a/api/@ohos.app.ability.Configuration.d.ts b/api/@ohos.app.ability.Configuration.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5f11c28d254a422316cb7a48353ad53dc13344f --- /dev/null +++ b/api/@ohos.app.ability.Configuration.d.ts @@ -0,0 +1,72 @@ +/* + * 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 ConfigurationConstant from "./@ohos.app.ability.ConfigurationConstant"; + +/** + * configuration item. + * @typedef Configuration + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ +export interface Configuration { + /** + * Indicates the current language of the application. + * @type { string } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + language?: string; + + /** + * Indicates the current colorMode of the application. + * @type { ConfigurationConstant.ColorMode } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + colorMode?: ConfigurationConstant.ColorMode; + + /** + * Indicates the screen direction of the current device. + * @type { ConfigurationConstant.Direction } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + direction?: ConfigurationConstant.Direction; + + /** + * Indicates the screen density of the current device. + * @type { ConfigurationConstant.ScreenDensity } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + screenDensity?: ConfigurationConstant.ScreenDensity; + + /** + * Indicates the displayId of the current device. + * @type { number } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + displayId?: number; + + /** + * Indicates whether a pointer type device has connected. + * @type { boolean } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + hasPointerDevice?: boolean; +} diff --git a/api/@ohos.app.ability.ConfigurationConstant.d.ts b/api/@ohos.app.ability.ConfigurationConstant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..303647c93b6833a7286bb4c86b5de53172822a13 --- /dev/null +++ b/api/@ohos.app.ability.ConfigurationConstant.d.ts @@ -0,0 +1,65 @@ +/* + * 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. + * @namespace ConfigurationConstant + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + declare namespace ConfigurationConstant { + /** + * ColorMode + * @enum { number } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + export enum ColorMode { + COLOR_MODE_NOT_SET = -1, + COLOR_MODE_DARK = 0, + COLOR_MODE_LIGHT = 1, + } + + /** + * Direction + * @enum { number } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + export enum Direction { + DIRECTION_NOT_SET = -1, + DIRECTION_VERTICAL = 0, + DIRECTION_HORIZONTAL = 1, + } + + /** + * ScreenDensity + * @name ScreenDensity + * @enum { number } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + 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/api/@ohos.app.ability.EnvironmentCallback.d.ts b/api/@ohos.app.ability.EnvironmentCallback.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..03ccc013c37461487b4f203be3cd28940f895697 --- /dev/null +++ b/api/@ohos.app.ability.EnvironmentCallback.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. + */ + +import { Configuration } from './@ohos.app.ability.Configuration'; + +/** + * The environment callback. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ +export default class EnvironmentCallback { + /** + * Called when the system configuration is updated. + * @param { Configuration } config - Indicates the updated configuration. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onConfigurationUpdated(config: Configuration): void; +} diff --git a/api/@ohos.app.ability.ExtensionAbility.d.ts b/api/@ohos.app.ability.ExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a64ecb161e9887aca48ece2a3f75be8bd3373247 --- /dev/null +++ b/api/@ohos.app.ability.ExtensionAbility.d.ts @@ -0,0 +1,25 @@ +/* + * 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.app.ability.Ability"; + +/** + * class of extension. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ +export default class ExtensionAbility extends Ability { +} diff --git a/api/@ohos.app.ability.ServiceExtensionAbility.d.ts b/api/@ohos.app.ability.ServiceExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d4eaab2f12079d274012c15d2d4b5c9b5a8ae94d --- /dev/null +++ b/api/@ohos.app.ability.ServiceExtensionAbility.d.ts @@ -0,0 +1,122 @@ +/* + * 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 rpc from "./@ohos.rpc"; +import ServiceExtensionContext from "./application/ServiceExtensionContext"; +import Want from './@ohos.app.ability.Want'; +import { Configuration } from './@ohos.app.ability.Configuration'; + +/** + * class of service extension ability. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ +export default class ServiceExtensionAbility { + /** + * Indicates service extension ability context. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + context: ServiceExtensionContext; + + /** + * Called back when a service extension is started for initialization. + * @param { Want } want - Indicates the want of created service extension. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onCreate(want: Want): void; + + /** + * Called back before a service extension is destroyed. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onDestroy(): void; + + /** + * Called back when a service extension is started. + * @param { Want } want - Indicates the want of service extension to start. + * @param { number } startId - Indicates the number of times the service extension has been started. + * The {@code startId} is incremented by 1 every time the service extension is started. + * For example, if the service extension has been started for six times. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onRequest(want: Want, startId: number): void; + + /** + * Called back when a service extension is first connected to an ability. + * @param { Want } want - Indicates connection information about the Service ability. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onConnect(want: Want): rpc.RemoteObject; + + /** + * Called back when all abilities connected to a service extension are disconnected. + * @param { Want } want - Indicates disconnection information about the service extension. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onDisconnect(want: Want): void; + + /** + * Called when a new client attempts to connect to a service extension after all previous client connections to it + * are disconnected. + * @param { Want } want - Indicates the want of the service extension being connected. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onReconnect(want: Want): void; + + /** + * Called when the system configuration is updated. + * @param { Configuration } newConfig - Indicates the updated configuration. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onConfigurationUpdate(newConfig: Configuration): void; + + /** + * Called when dump client information is required. + * It is recommended that developers don't DUMP sensitive information. + * @param { Array } params - Indicates the params from command. + * @return { Array } The dump info array. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + onDump(params: Array): Array; +} diff --git a/api/bundle/dispatchInfo.d.ts b/api/@ohos.app.ability.StartOptions.d.ts similarity index 59% rename from api/bundle/dispatchInfo.d.ts rename to api/@ohos.app.ability.StartOptions.d.ts index 2538eb4c831ea6986e6501eec53294e77820b8ba..2650fce27a14a68529ff154d9b2f25d1f6c55f56 100644 --- a/api/bundle/dispatchInfo.d.ts +++ b/api/@ohos.app.ability.StartOptions.d.ts @@ -14,23 +14,25 @@ */ /** - * @name The dispatch info class. + * StartOptions is the basic communication component of the system. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use */ - export interface DispatchInfo { +export default class StartOptions { /** - * @default Indicates the dispatchInfo version + * windowMode + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework */ - readonly version: string; - + windowMode?: number; + /** - * @default Indicates the free install interface version number + * displayId + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework */ - readonly dispatchAPI: string; + displayId?: number; } \ No newline at end of file diff --git a/api/@ohos.app.ability.UIAbility.d.ts b/api/@ohos.app.ability.UIAbility.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..2f1612dc5ce69bb797ea67d11ebb3f21b5f17544 --- /dev/null +++ b/api/@ohos.app.ability.UIAbility.d.ts @@ -0,0 +1,292 @@ +/* + * 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.app.ability.Ability"; +import AbilityConstant from "./@ohos.app.ability.AbilityConstant"; +import UIAbilityContext from "./application/UIAbilityContext"; +import rpc from './@ohos.rpc'; +import Want from './@ohos.app.ability.Want'; +import window from './@ohos.window'; + +/** + * The prototype of the listener function interface registered by the Caller. + * @typedef OnReleaseCallback + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface OnReleaseCallback { + (msg: string): void; +} + +/** + * The prototype of the message listener function interface registered by the Callee. + * @typedef CalleeCallback + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface CalleeCallback { + (indata: rpc.MessageParcel): rpc.Sequenceable; +} + +/** + * The interface of a Caller. + * @interface + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface Caller { + /** + * Notify the server of Sequenceable type data. + * @param { string } method - The notification event string listened to by the callee. + * @param { rpc.Sequenceable } data - Notification data to the callee. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + call(method: string, data: rpc.Sequenceable): Promise; + + /** + * Notify the server of Sequenceable type data and return the notification result. + * @param { string } method - The notification event string listened to by the callee. + * @param { rpc.Sequenceable } data - Notification data to the callee. + * @returns { Promise } Returns the callee's notification result data. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + callWithResult(method: string, data: rpc.Sequenceable): Promise; + + /** + * Clear service records. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + release(): void; + + /** + * Register death listener notification callback. + * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onRelease(callback: OnReleaseCallback): void; + + /** + * Register death listener notification callback. + * @param { string } type - release. + * @param { OnReleaseCallback } callback - Register a callback function for listening for notifications. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + on(type: "release", callback: OnReleaseCallback): void; + + /** + * Unregister death listener notification callback. + * @param { string } type - release. + * @param { OnReleaseCallback } callback - Unregister a callback function for listening for notifications. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + off(type: "release", callback: OnReleaseCallback): void; + + /** + * Unregister all death listener notification callback. + * @param { string } type - release. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + off(type: "release"): void; +} + +/** + * The interface of a Callee. + * @interface + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export interface Callee { + /** + * Register data listener callback. + * @param { string } method - A string registered to listen for notification events. + * @param { CalleeCallback } callback - Register a callback function that listens for notification events. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + on(method: string, callback: CalleeCallback): void; + + /** + * Unregister data listener callback. + * @param { string } method - A string registered to listen for notification events. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + off(method: string): void; +} + +/** + * The class of a UI ability. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ +export default class UIAbility extends Ability { + /** + * Indicates configuration information about an ability context. + * @type { UIAbilityContext } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + context: UIAbilityContext; + + /** + * Indicates ability launch want. + * @type { Want } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + launchWant: Want; + + /** + * Indicates ability last request want. + * @type { Want } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + lastRequestWant: Want; + + /** + * Call Service Stub Object. + * @type { Callee } + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + callee: Callee; + + /** + * Called back when an ability is started for initialization. + * @param { Want } want - Indicates the want info of the created ability. + * @param { AbilityConstant.LaunchParam } param - Indicates the launch param. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onCreate(want: Want, param: AbilityConstant.LaunchParam): void; + + /** + * Called back when an ability window stage is created. + * @param { window.WindowStage } windowStage - Indicates the created WindowStage. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageCreate(windowStage: window.WindowStage): void; + + /** + * Called back when an ability window stage is destroyed. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageDestroy(): void; + + /** + * Called back when an ability window stage is restored. + * @param { window.WindowStage } windowStage - window stage to restore + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onWindowStageRestore(windowStage: window.WindowStage): void; + + /** + * Called back before an ability is destroyed. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onDestroy(): void; + + /** + * Called back when the state of an ability changes to foreground. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onForeground(): void; + + /** + * Called back when the state of an ability changes to background. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onBackground(): void; + + /** + * Called back when an ability prepares to continue. + * @param { {[key: string]: any} } wantParam - Indicates the want parameter. + * @returns { AbilityConstant.OnContinueResult } Return the result of onContinue. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + 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. + * @param { Want } want - Indicates the want info of ability. + * @param { AbilityConstant.LaunchParam } launchParams - Indicates the launch parameters. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void; + + /** + * Called when dump client information is required. + * It is recommended that developers don't DUMP sensitive information. + * @param { Array } params - Indicates the params from command. + * @returns { Array } Return the dump info array. + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @stagemodelonly + * @since 9 + */ + onDump(params: Array): Array; +} diff --git a/api/@ohos.app.ability.Want.d.ts b/api/@ohos.app.ability.Want.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..39f02017e5703848cbd06d7cd865bc758eea8d3e --- /dev/null +++ b/api/@ohos.app.ability.Want.d.ts @@ -0,0 +1,91 @@ +/* + * 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. + */ + +/** + * Want is the basic communication component of the system. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ +export default class Want { + /** + * device id + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + deviceId?: string; + + /** + * bundle name + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + bundleName?: string; + + /** + * ability name + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + abilityName?: string; + + /** + * The description of a URI in a Want. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + uri?: string; + + /** + * The description of the type in this Want. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + type?: string; + + /** + * The options of the flags in this Want. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + flags?: number; + + /** + * The description of an action in an want. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + action?: string; + + /** + * The description of the WantParams object in an Want + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + parameters?: {[key: string]: any}; + + /** + * The description of a entities in a Want. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + entities?: Array; + + /** + * The description of an module name in an want. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + moduleName?: string; +} diff --git a/api/@ohos.app.ability.abilityDelegatorRegistry.d.ts b/api/@ohos.app.ability.abilityDelegatorRegistry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3177d986c0fc589bbfc0769d8b6ec098d8c5206 --- /dev/null +++ b/api/@ohos.app.ability.abilityDelegatorRegistry.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 { AbilityDelegator as _AbilityDelegator } from './application/abilityDelegator'; +import { AbilityDelegatorArgs as _AbilityDelegatorArgs } from './application/abilityDelegatorArgs'; +import { AbilityMonitor as _AbilityMonitor } from './application/abilityMonitor'; +import { ShellCmdResult as _ShellCmdResult } from './application/shellCmdResult'; + +/** + * A global register used to store the AbilityDelegator and AbilityDelegatorArgs objects registered + * during application startup. + * @namespace abilityDelegatorRegistry + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ +declare namespace abilityDelegatorRegistry { + /** + * Get the AbilityDelegator object of the application. + * @returns { AbilityDelegator } Return the AbilityDelegator object initialized when the application is started. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getAbilityDelegator(): AbilityDelegator; + + /** + * Get unit test arguments stored in the AbilityDelegatorArgs object. + * @returns { AbilityDelegator } Return the previously registered AbilityDelegatorArgs object. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getArguments(): AbilityDelegatorArgs; + + /** + * Describes all lifecycle states of an ability. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export enum AbilityLifecycleState { + UNINITIALIZED, + CREATE, + FOREGROUND, + BACKGROUND, + DESTROY, + } + + /** + * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type AbilityDelegator = _AbilityDelegator + + /** + * Store unit testing-related parameters, including test case names, and test runner name. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type AbilityDelegatorArgs = _AbilityDelegatorArgs + + /** + * Provide methods for matching monitored Ability objects that meet specified conditions. + * The most recently matched Ability objects will be saved in the AbilityMonitor object. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type AbilityMonitor = _AbilityMonitor + + /** + * A object that records the result of shell command executes. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type ShellCmdResult = _ShellCmdResult +} + +export default abilityDelegatorRegistry; \ No newline at end of file diff --git a/api/@ohos.app.ability.abilityManager.d.ts b/api/@ohos.app.ability.abilityManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7775354d941dea6afb4fe6692f84056445ab1b8 --- /dev/null +++ b/api/@ohos.app.ability.abilityManager.d.ts @@ -0,0 +1,152 @@ +/* + * 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 { Configuration } from './@ohos.app.ability.Configuration'; +import { AbilityRunningInfo as _AbilityRunningInfo } from './application/AbilityRunningInfo'; +import { ExtensionRunningInfo as _ExtensionRunningInfo } from './application/ExtensionRunningInfo'; +import { ElementName } from './bundleManager/elementName'; + +/** + * The class of an ability manager. + * @namespace abilityManager + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ +declare namespace abilityManager { + /** + * Enum for the ability state + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export enum AbilityState { + INITIAL = 0, + FOREGROUND = 9, + BACKGROUND = 10, + FOREGROUNDING = 11, + BACKGROUNDING = 12 + } + + /** + * Updates the configuration by modifying the configuration. + * @permission ohos.permission.UPDATE_CONFIGURATION + * @param { Configuration } config - Indicates the new configuration. + * @param { AsyncCallback } callback - The callback of updateConfiguration. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function updateConfiguration(config: Configuration, callback: AsyncCallback): void; + + /** + * Updates the configuration by modifying the configuration. + * @permission ohos.permission.UPDATE_CONFIGURATION + * @param { Configuration } config - Indicates the new configuration. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function updateConfiguration(config: Configuration): Promise; + + /** + * Get information about running abilities + * @permission ohos.permission.GET_RUNNING_INFO + * @returns { Promise> } Returns the array of AbilityRunningInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getAbilityRunningInfos(): Promise>; + + /** + * Get information about the running ability + * @permission ohos.permission.GET_RUNNING_INFO + * @param { AsyncCallback> } callback - The callback is used to return the array of AbilityRunningInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getAbilityRunningInfos(callback: AsyncCallback>): void; + + /** + * Get information about running extensions + * @permission ohos.permission.GET_RUNNING_INFO + * @param { number } upperLimit - Get the maximum limit of the number of messages. + * @returns { Promise> } Returns the array of ExtensionRunningInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getExtensionRunningInfos(upperLimit: number): Promise>; + + /** + * Get information about running extensions + * @permission ohos.permission.GET_RUNNING_INFO + * @param { number } upperLimit - Get the maximum limit of the number of messages. + * @param { AsyncCallback> } callback - The callback is used to return the array of ExtensionRunningInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback>): void; + + /** + * Get the top ability information of the display. + * @returns { Promise } Returns the elementName info of the top ability. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getTopAbility(): Promise; + + /** + * Get the top ability information of the display. + * @param { AsyncCallback } callback - The callback is used to return the elementName info of the top ability. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getTopAbility(callback: AsyncCallback): void; + + /** + * The class of an ability running information. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export type AbilityRunningInfo = _AbilityRunningInfo + + /** + * The class of an extension running information. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export type ExtensionRunningInfo = _ExtensionRunningInfo +} + +export default abilityManager; \ No newline at end of file diff --git a/api/@ohos.app.ability.appManager.d.ts b/api/@ohos.app.ability.appManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ebc1872c806476003af7a702ab638aa3c065cb1a --- /dev/null +++ b/api/@ohos.app.ability.appManager.d.ts @@ -0,0 +1,325 @@ +/* + * 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 * as _ApplicationStateObserver from './application/ApplicationStateObserver'; +import * as _AbilityStateData from './application/AbilityStateData'; +import * as _AppStateData from './application/AppStateData'; +import { ProcessRunningInfo as _ProcessRunningInfo } from './application/ProcessRunningInfo'; +import { ProcessRunningInformation as _ProcessRunningInformation } from './application/ProcessRunningInformation'; + +/** + * This module provides the function of app manager service. + * @namespace appManager + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + * + */ +declare namespace appManager { + /** + * Enum for the application state + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export enum ApplicationState { + STATE_CREATE, + STATE_FOREGROUND, + STATE_ACTIVE, + STATE_BACKGROUND, + STATE_DESTROY + } + + /** + * Enum for the process state + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export enum ProcessState { + STATE_CREATE, + STATE_FOREGROUND, + STATE_ACTIVE, + STATE_BACKGROUND, + STATE_DESTROY + } + + /** + * Register application state observer. + * @permission ohos.permission.RUNNING_STATE_OBSERVER + * @param { string } type - applicationState. + * @param { ApplicationStateObserver } observer - The application state observer. + * @return { number } Returns the number code of the observer. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function on(type: "applicationState", observer: ApplicationStateObserver): number; + + /** + * Register application state observer. + * @permission ohos.permission.RUNNING_STATE_OBSERVER + * @param { string } type - applicationState. + * @param { ApplicationStateObserver } observer - The application state observer. + * @param { Array } bundleNameList - The list of bundleName. The max length is 128. + * @return { number } Returns the number code of the observer. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function on(type: "applicationState", observer: ApplicationStateObserver, bundleNameList: Array): number; + + /** + * Unregister application state observer. + * @permission ohos.permission.RUNNING_STATE_OBSERVER + * @param { string } type - applicationState. + * @param { number } observerId - Indicates the number code of the observer. + * @param { AsyncCallback } callback - The callback of off. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function off(type: "applicationState", observerId: number, callback: AsyncCallback): void; + + /** + * Unregister application state observer. + * @permission ohos.permission.RUNNING_STATE_OBSERVER + * @param { string } type - applicationState. + * @param { number } observerId - Indicates the number code of the observer. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function off(type: "applicationState", observerId: number): Promise; + + /** + * getForegroundApplications. + * @permission ohos.permission.GET_RUNNING_INFO + * @param { AsyncCallback> } callback - The callback is used to return the list of AppStateData. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getForegroundApplications(callback: AsyncCallback>): void; + + /** + * getForegroundApplications. + * @permission ohos.permission.GET_RUNNING_INFO + * @returns { Promise> } Returns the list of AppStateData. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getForegroundApplications(): Promise>; + + /** + * Kill process with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES + * @param { string } bundleName - The process bundle name. + * @param { number } accountId - The account id. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function killProcessWithAccount(bundleName: string, accountId: number): Promise; + + /** + * Kill process with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS and ohos.permission.CLEAN_BACKGROUND_PROCESSES + * @param { string } bundleName - The process bundle name. + * @param { number } accountId - The account id. + * @param { AsyncCallback } callback - The callback of killProcessWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCallback): void; + + /** + * Is user running in stability test. + * @param { AsyncCallback } callback - The callback is used to return true if user is running stability test. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function isRunningInStabilityTest(callback: AsyncCallback): void; + + /** + * Is user running in stability test. + * @returns { Promise } Returns true if user is running stability test. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function isRunningInStabilityTest(): Promise; + + /** + * Kill processes by bundle name + * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES + * @param { string } bundleName - bundle name. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function killProcessesByBundleName(bundleName: string): Promise; + + /** + * Kill processes by bundle name + * @permission ohos.permission.CLEAN_BACKGROUND_PROCESSES + * @param { string } bundleName - bundle name. + * @param { AsyncCallback } callback - The callback of killProcessesByBundleName. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function killProcessesByBundleName(bundleName: string, callback: AsyncCallback); + + /** + * Clear up application data by bundle name + * @permission ohos.permission.CLEAN_APPLICATION_DATA + * @param { string } bundleName - bundle name. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function clearUpApplicationData(bundleName: string): Promise; + + /** + * Clear up application data by bundle name + * @permission ohos.permission.CLEAN_APPLICATION_DATA + * @param { string } bundleName - bundle name. + * @param { AsyncCallback } callback - The callback of clearUpApplicationData. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function clearUpApplicationData(bundleName: string, callback: AsyncCallback); + + /** + * Is it a ram-constrained device + * @returns { Promise } Returns true if the device is ram-constrained. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function isRamConstrainedDevice(): Promise; + + /** + * Is it a ram-constrained device + * @param { AsyncCallback } callback - The callback is used to return true if the device is ram-constrained. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function isRamConstrainedDevice(callback: AsyncCallback): void; + + /** + * Get the memory size of the application + * @returns { Promise } Returns the application memory size. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getAppMemorySize(): Promise; + + /** + * Get the memory size of the application + * @param { AsyncCallback } callback - The callback is used to return the application memory size. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getAppMemorySize(callback: AsyncCallback): void; + + /** + * Get information about running processes + * @permission ohos.permission.GET_RUNNING_INFO + * @returns { Promise> } Returns the array of {@link ProcessRunningInformation}. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getProcessRunningInformation(): Promise>; + + /** + * Get information about running processes + * @permission ohos.permission.GET_RUNNING_INFO + * @param { AsyncCallback> } callback - The callback is used to return the array of {@link ProcessRunningInformation}. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getProcessRunningInformation(callback: AsyncCallback>): void; + + /** + * The ability or extension state data. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export type AbilityStateData = _AbilityStateData.default + + /** + * The application state data. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export type AppStateData = _AppStateData.default + + /** + * The application state observer. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + export type ApplicationStateObserver = _ApplicationStateObserver.default + + /** + * The class of an process running information. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type ProcessRunningInfo = _ProcessRunningInfo + + /** + * The class of a process running information. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type ProcessRunningInformation = _ProcessRunningInformation +} + +export default appManager; diff --git a/api/@ohos.app.ability.appRecovery.d.ts b/api/@ohos.app.ability.appRecovery.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9c1cad363145933e7b7fe486906ea252737a17c --- /dev/null +++ b/api/@ohos.app.ability.appRecovery.d.ts @@ -0,0 +1,121 @@ +/* + * 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 app receovery. + * @import appReceovery from '@ohos.app.ability.appRecovery' + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ +declare namespace appReceovery { + /** + * The type of no restart mode. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + enum RestartFlag { + /** + * NONE: no restart restrictions + */ + ALWAYS_RESTART = 0, + + /** + * CPP_CRASH_NO_RESTART: Do not restart if process terminates due to cpp exception + */ + CPP_CRASH_NO_RESTART = 0x0001, + + /** + * JS_CRASH_NO_RESTART: Do not restart if process terminates due to js/ts/ets exception + */ + JS_CRASH_NO_RESTART = 0x0002, + + /** + * APP_FREEZE_NO_RESTART: Do not restart if process terminates due to appliction not respondong + */ + APP_FREEZE_NO_RESTART = 0x0004, + + /** + * NO_RESTART: Do not restart + */ + NO_RESTART = 0xFFFF, + } + + /** + * The type of when to save. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + enum SaveOccasionFlag { + /** + * SAVE_WHEN_ERROR is saving when an error occurs. + */ + SAVE_WHEN_ERROR = 0x0001, + + /** + * SAVE_WHEN_CREATE is saving on background. + */ + SAVE_WHEN_BACKGROUND = 0x0002, + } + + /** + * The type of where to save. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + enum SaveModeFlag { + /** + * SAVE_WITH_FILE is saving to file. + */ + SAVE_WITH_FILE = 0x0001, + + /** + * SAVE_WITH_SHARED_MEMORY is saving to shared memory. + */ + SAVE_WITH_SHARED_MEMORY = 0x0002, + } + + /** + * Enable appRecovery and app supports save and restore + * @param restart no restart mode + * @param saveOccasion The type of When to save + * @param saveMode The type of where to save + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + function enableAppRecovery(restart?: RestartFlag, saveOccasion?: SaveOccasionFlag, saveMode?: SaveModeFlag) : void; + + /** + * Restart App when called + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + function restartApp(): void; + + /** + * Save App state data when called + * @return true if save data successfully, otherwise false + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + function saveAppState(): boolean; +} + +export default appReceovery; \ No newline at end of file diff --git a/api/@ohos.app.ability.common.d.ts b/api/@ohos.app.ability.common.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..cd0a1046cbfb1237c4824ace68739dd011e38119 --- /dev/null +++ b/api/@ohos.app.ability.common.d.ts @@ -0,0 +1,152 @@ +/* + * 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 * as _UIAbilityContext from './application/UIAbilityContext'; +import * as _AbilityStageContext from './application/AbilityStageContext'; +import * as _ApplicationContext from './application/ApplicationContext'; +import * as _BaseContext from './application/BaseContext'; +import * as _Context from './application/Context'; +import * as _ExtensionContext from './application/ExtensionContext'; +import * as _FormExtensionContext from './application/FormExtensionContext'; +import * as _EventHub from './application/EventHub'; +import * as _PermissionRequestResult from './application/PermissionRequestResult'; +import { PacMap as _PacMap } from "./ability/dataAbilityHelper"; +import { AbilityResult as _AbilityResult } from "./ability/abilityResult"; +import { ConnectOptions as _ConnectOptions } from "./ability/connectOptions"; + +/** + * The context of an application. It allows access to application-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ +declare namespace common { + + /** + * The context of an ability. It allows access to ability-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type UIAbilityContext = _UIAbilityContext.default + + /** + * The context of an abilityStage. It allows access to abilityStage-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type AbilityStageContext = _AbilityStageContext.default + + /** + * The context of an application. It allows access to application-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type ApplicationContext = _ApplicationContext.default + + /** + * The base context of 'app.Context' for FA Mode or 'application.Context' for Stage Mode. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type BaseContext = _BaseContext.default + + /** + * The base context of an ability or an application. It allows access to + * application-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type Context = _Context.default + + /** + * The context of an extension. It allows access to extension-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type ExtensionContext = _ExtensionContext.default + + /** + * The context of form extension. It allows access to + * formExtension-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type FormExtensionContext = _FormExtensionContext.default + + /** + * File area mode + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export enum AreaMode { + /** + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + EL1 = 0, + /** + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + EL2 = 1 + } + + /** + * The event center of a context, support the subscription and publication of events. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type EventHub = _EventHub.default + + /** + * The result of requestPermissionsFromUser with asynchronous callback. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type PermissionRequestResult = _PermissionRequestResult.default + + /** + * Defines a PacMap object for storing a series of values. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type PacMap = _PacMap + + /** + * Indicates the result of startAbility. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type AbilityResult = _AbilityResult + + /** + * Indicates the callback of connection + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + export type ConnectOptions = _ConnectOptions +} + +export default common; diff --git a/api/@ohos.uiAppearance.d.ts b/api/@ohos.app.ability.contextConstant.d.ts similarity index 40% rename from api/@ohos.uiAppearance.d.ts rename to api/@ohos.app.ability.contextConstant.d.ts index 5a65a569d5106e0c737b7aa6d57bfb22f4bfea58..fef30c258137c93aa886274469405968c2b1e884 100644 --- a/api/@ohos.uiAppearance.d.ts +++ b/api/@ohos.app.ability.contextConstant.d.ts @@ -13,45 +13,35 @@ * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; - /** - * Provide APIs to set system uiAppearance. - * @syscap SystemCapability.ArkUI.UiAppearance - * @import import uiAppearance from '@ohos.uiAppearance'; + * The context of an application. It allows access to application-specific resources. + * * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly */ -declare namespace uiAppearance { + declare namespace contextConstant { + /** - * Enumerates dark-mode. + * File area mode + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly */ - enum DarkMode { + export enum AreaMode { /** - * Always display with dark mode. + * System level device encryption area + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - ALWAYS_DARK = 0, + EL1 = 0, /** - * Always display with light mode. + * User credential encryption area + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - ALWAYS_LIGHT = 1 + EL2 = 1 } - - /** - * Set the system dark-mode. - * @param mode Indicates the dark-mode to set - * @permission ohos.permission.UPDATE_CONFIGURATION - * @systemapi Hide this for inner system use - */ - function setDarkMode(mode: DarkMode, callback: AsyncCallback): void; - function setDarkMode(mode: DarkMode): Promise; - - /** - * Acquire the current dark-mode. - * @return current dark-mode. - * @permission ohos.permission.UPDATE_CONFIGURATION - * @systemapi Hide this for inner system use - */ - function getDarkMode(): DarkMode; } -export default uiAppearance; \ No newline at end of file + +export default contextConstant; \ No newline at end of file diff --git a/api/@ohos.app.ability.errorManager.d.ts b/api/@ohos.app.ability.errorManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..10573f876d2656e024b895b74ab3b8210e0b2bad --- /dev/null +++ b/api/@ohos.app.ability.errorManager.d.ts @@ -0,0 +1,67 @@ +/* + * 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 * as _ErrorObserver from './application/ErrorObserver'; + +/** + * This module provides the function of error manager. + * @namespace errorManager + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ +declare namespace errorManager { + /** + * Register error observer. + * @param { string } type - error. + * @param { ErrorObserver } observer - The error observer. + * @returns { number } Returns the number code of the observer. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function on(type: "error", observer: ErrorObserver): number; + + /** + * Unregister error observer. + * @param { string } type - error. + * @param { number } observerId - Indicates the number code of the observer. + * @param { AsyncCallback } callback - The callback of off. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function off(type: "error", observerId: number, callback: AsyncCallback): void; + + /** + * Unregister error observer. + * @param { string } type - error. + * @param { number } observerId - Indicates the number code of the observer. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function off(type: "error", observerId: number): Promise; + + /** + * The observer will be called by system when an error occurs. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type ErrorObserver = _ErrorObserver.default +} + +export default errorManager; diff --git a/api/@ohos.app.ability.missionManager.d.ts b/api/@ohos.app.ability.missionManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..efbed8686fd8d8b3373662f62c44f30e296334ac --- /dev/null +++ b/api/@ohos.app.ability.missionManager.d.ts @@ -0,0 +1,287 @@ +/* + * 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 { MissionInfo as _MissionInfo } from './application/MissionInfo'; +import { MissionListener as _MissionListener } from './application/MissionListener'; +import { MissionSnapshot as _MissionSnapshot } from './application/MissionSnapshot'; +import StartOptions from "./@ohos.app.ability.StartOptions"; + +/** + * This module provides the capability to manage abilities and obtaining system task information. + * @permission ohos.permission.MANAGE_MISSIONS + * @namespace missionManager + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi + * @since 9 + */ +declare namespace missionManager { + /** + * Register the missionListener to ams. + * @param { string } type - mission. + * @param { MissionListener } listener - Indicates the MissionListener to be registered. + * @returns { number } Returns the index number of the MissionListener. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function on(type: "mission", listener: MissionListener): number; + + /** + * Unrgister the missionListener to ams. + * @param { string } type - mission. + * @param { number } listenerId - Indicates the listener id to be unregistered. + * @param { AsyncCallback } callback - The callback of off. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function off(type: "mission", listenerId: number, callback: AsyncCallback): void; + + /** + * Unrgister the missionListener to ams. + * @param { string } type - mission. + * @param { number } listenerId - Indicates the listener id to be unregistered. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function off(type: "mission", listenerId: number): Promise; + + /** + * Get the missionInfo with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } missionId - Indicates mission id to be queried. + * @param { AsyncCallback } callback - The callback is used to return the MissionInfo of the given id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback): void; + + /** + * Get the missionInfo with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } missionId - Indicates mission id to be queried. + * @returns { Promise } Returns the MissionInfo of the given id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getMissionInfo(deviceId: string, missionId: number): Promise; + + /** + * Get the missionInfo with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } numMax - Indicates the maximum number of returned missions. + * @param { AsyncCallback> } callback - The callback is used to return the array of the MissionInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback>): void; + + /** + * Get the missionInfo with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } numMax - Indicates the maximum number of returned missions. + * @returns { Promise> } Returns the array of the MissionInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getMissionInfos(deviceId: string, numMax: number): Promise>; + + /** + * Get the mission snapshot with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } missionId - Indicates mission id to be queried. + * @param { AsyncCallback } callback - The callback is used to return the MissionSnapshot of the given id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback): void; + + /** + * Get the mission snapshot with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } missionId - Indicates mission id to be queried. + * @returns { Promise } Returns the MissionSnapshot of the given id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getMissionSnapShot(deviceId: string, missionId: number): Promise; + + /** + * Get the mission low resolution snapshot with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } missionId - Indicates mission id to be queried. + * @param { AsyncCallback } callback - The callback is used to return the MissionSnapshot of the given id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback): void; + + /** + * Get the mission low resolution snapshot with the given missionId. + * @param { string } deviceId - Indicates the device to be queried. + * @param { number } missionId - Indicates mission id to be queried. + * @returns { Promise } Returns the MissionSnapshot of the given id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise; + + /** + * Lock the mission. + * @param { number } missionId - Indicates mission id to be locked. + * @param { AsyncCallback } callback - The callback of lockMission. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function lockMission(missionId: number, callback: AsyncCallback): void; + + /** + * Lock the mission. + * @param { number } missionId - Indicates mission id to be locked. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function lockMission(missionId: number): Promise; + + /** + * Unlock the mission. + * @param { number } missionId - Indicates mission id to be unlocked. + * @param { AsyncCallback } callback - The callback of unlockMission. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function unlockMission(missionId: number, callback: AsyncCallback): void; + + /** + * Unlock the mission. + * @param { number } missionId - Indicates mission id to be unlocked. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function unlockMission(missionId: number): Promise; + + /** + * Clear the given mission in the ability manager service. + * @param { number } missionId - Indicates mission id to be cleared. + * @param { AsyncCallback } callback - The callback of clearMission. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function clearMission(missionId: number, callback: AsyncCallback): void; + + /** + * Clear the given mission in the ability manager service. + * @param { number } missionId - Indicates mission id to be cleared. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function clearMission(missionId: number): Promise; + + /** + * Clear all missions in the ability manager service. + * @param { AsyncCallback } callback - The callback of clearAllMissions. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function clearAllMissions(callback: AsyncCallback): void; + + /** + * Clear all missions in the ability manager service. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function clearAllMissions(): Promise; + + /** + * Schedule the given mission to foreground. + * @param { number } missionId - Indicates mission id to be moved to foreground. + * @param { AsyncCallback } callback - The callback of moveMissionToFront. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function moveMissionToFront(missionId: number, callback: AsyncCallback): void; + + /** + * Schedule the given mission to foreground. + * @param { number } missionId - Indicates mission id to be moved to foreground. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of moveMissionToFront. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Schedule the given mission to foreground. + * @param { number } missionId - Indicates mission id to be moved to foreground. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @since 9 + */ + function moveMissionToFront(missionId: number, options?: StartOptions): Promise; + + /** + * Mission information corresponding to ability. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi + * @since 9 + */ + export type MissionInfo = _MissionInfo + + /** + * MissionListener registered by app. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi + * @since 9 + */ + export type MissionListener = _MissionListener + + /** + * Mission snapshot corresponding to mission. + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @systemapi + * @since 9 + */ + export type MissionSnapshot = _MissionSnapshot +} + +export default missionManager; \ No newline at end of file diff --git a/api/@ohos.application.quickFixManager.d.ts b/api/@ohos.app.ability.quickFixManager.d.ts similarity index 58% rename from api/@ohos.application.quickFixManager.d.ts rename to api/@ohos.app.ability.quickFixManager.d.ts index d30e16fe0359d8994441e76fc13321cff46eaf58..89cf51bc871e11911812bfe0513f681c01cf14f4 100644 --- a/api/@ohos.application.quickFixManager.d.ts +++ b/api/@ohos.app.ability.quickFixManager.d.ts @@ -17,137 +17,160 @@ import { AsyncCallback } from "./basic"; /** * Interface of quickFixManager. - * - * @name quickFixManager - * @since 9 + * @namespace quickFixManager * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ declare namespace quickFixManager { /** * Quick fix info of hap module. - * - * @since 9 + * @typedef HapModuleQuickFixInfo * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ export interface HapModuleQuickFixInfo { /** * Indicates hap module name. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly moduleName: string; /** * Indicates hash value of a hap. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly originHapHash: string; /** * Indicates installed path of quick fix file. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly quickFixFilePath: string; } /** * Quick fix info of application. - * - * @since 9 + * @typedef ApplicationQuickFixInfo * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ export interface ApplicationQuickFixInfo { /** * Bundle name. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly bundleName: string; /** * The version number of the bundle. - * - * @since 9 + * @type { number } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly bundleVersionCode: number; /** * The version name of the bundle. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly bundleVersionName: string; /** * The version number of the quick fix. - * - * @since 9 + * @type { number } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly quickFixVersionCode: number; /** * The version name of the quick fix. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly quickFixVersionName: string; /** * Hap module quick fix info. - * - * @since 9 + * @type { Array } * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @systemapi Hide this for inner system use. + * @systemapi + * @since 9 */ readonly hapModuleQuickFixInfo: Array; } /** * Apply quick fix files. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @param hapModuleQuickFixFiles Quick fix files need to apply, this value should include file path and file name. - * @systemapi Hide this for inner system use. - * @return - * @permission ohos.permission.INSTALL_BUNDLE + * @param { Array } hapModuleQuickFixFiles - Quick fix files need to apply, this value should include file + * path and file name. + * @param { AsyncCallback } callback - The callback of applyQuickFix. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix + * @systemapi + * @since 9 */ function applyQuickFix(hapModuleQuickFixFiles: Array, callback: AsyncCallback): void; + + /** + * Apply quick fix files. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { Array } hapModuleQuickFixFiles - Quick fix files need to apply, this value should include file + * path and file name. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix + * @systemapi + * @since 9 + */ function applyQuickFix(hapModuleQuickFixFiles: Array): Promise; /** * Get application quick fix info by bundle name. - * - * @since 9 + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Bundle name wish to query. + * @param { AsyncCallback } callback - The callback is used to return the ApplicationQuickFixInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix - * @param bundleName Bundle name wish to query. - * @systemapi Hide this for inner system use. - * @return Returns the {@link ApplicationQuickFixInfo}. + * @systemapi + * @since 9 + */ + function getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback): void; + + /** + * Get application quick fix info by bundle name. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Bundle name wish to query. + * @returns { Promise } Returns the ApplicationQuickFixInfo. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.QuickFix + * @systemapi + * @since 9 */ - function getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback): void; - function getApplicationQuickFixInfo(bundleName: string): Promise; + function getApplicationQuickFixInfo(bundleName: string): Promise; } export default quickFixManager; \ No newline at end of file diff --git a/api/@ohos.app.ability.wantAgent.d.ts b/api/@ohos.app.ability.wantAgent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ace81f0b4464298d5876d152a614b66e5bda32da --- /dev/null +++ b/api/@ohos.app.ability.wantAgent.d.ts @@ -0,0 +1,350 @@ +/* + * 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 Want from './@ohos.app.ability.Want'; +import { WantAgentInfo as _WantAgentInfo } from './wantAgent/wantAgentInfo'; +import { TriggerInfo as _TriggerInfo } from './wantAgent/triggerInfo'; + +/** + * Provide the method obtain trigger, cancel, and compare and to obtain + * the bundle name, UID of an {@link WantAgent} object. + * @namespace wantAgent + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ +declare namespace wantAgent { + /** + * Obtains the bundle name of a WantAgent. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { AsyncCallback } callback - The callback is used to return the bundle name. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getBundleName(agent: WantAgent, callback: AsyncCallback): void; + + /** + * Obtains the bundle name of a WantAgent. + * @param { WantAgent } agent - Indicates the WantAgent. + * @returns { Promise } Returns the bundle name. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getBundleName(agent: WantAgent): Promise; + + /** + * Obtains the UID of a WantAgent. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { AsyncCallback } callback - The callback is used to return the UID. + * @returns { Promise } Returns the UID. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getUid(agent: WantAgent, callback: AsyncCallback): void; + function getUid(agent: WantAgent): Promise; + + /** + * Obtains the {@link Want} of an {@link WantAgent}. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { AsyncCallback } callback - The callback is used to return the Want. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getWant(agent: WantAgent, callback: AsyncCallback): void; + + /** + * Obtains the {@link Want} of an {@link WantAgent}. + * @param { WantAgent } agent - Indicates the WantAgent. + * @returns { Promise } Returns the Want. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @since 9 + */ + function getWant(agent: WantAgent): Promise; + + /** + * Cancels a WantAgent. Only the application that creates the WantAgent can cancel it. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { AsyncCallback } callback - The callback of cancel. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function cancel(agent: WantAgent, callback: AsyncCallback): void; + + /** + * Cancels a WantAgent. Only the application that creates the WantAgent can cancel it. + * @param { WantAgent } agent - Indicates the WantAgent. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function cancel(agent: WantAgent): Promise; + + /** + * Triggers a WantAgent. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { TriggerInfo } triggerInfo - Indicates the information required for triggering a WantAgent. + * @param { Callback } callback - The callback is used to return the CompleteData. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: Callback): void; + + /** + * Triggers a WantAgent. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { TriggerInfo } triggerInfo - Indicates the information required for triggering a WantAgent. + * @param { AsyncCallback } callback - The callback is used to return the CompleteData. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback): void; + + /** + * Checks whether two WantAgent objects are equal. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { WantAgent } otherAgent - Indicates the other WantAgent. + * @param { AsyncCallback } callback - Returns true if the two WantAgents are the same. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function equal(agent: WantAgent, otherAgent: WantAgent, callback: AsyncCallback): void; + + /** + * Checks whether two WantAgent objects are equal. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { WantAgent } otherAgent - Indicates the other WantAgent. + * @returns { Promise } Returns true if the two WantAgents are the same. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function equal(agent: WantAgent, otherAgent: WantAgent): Promise; + + /** + * Obtains a WantAgent object. + * @param { WantAgentInfo } info - Information about the WantAgent object to obtain. + * @param { AsyncCallback } callback - The callback is used to return the created WantAgent. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getWantAgent(info: WantAgentInfo, callback: AsyncCallback): void; + + /** + * Obtains a WantAgent object. + * @param { WantAgentInfo } info - Information about the WantAgent object to obtain. + * @returns { Promise } Returns the created WantAgent. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getWantAgent(info: WantAgentInfo): Promise; + + /** + * Obtains the {@link OperationType} of a {@link WantAgent}. + * @param { WantAgent } agent - Indicates the WantAgent. + * @param { AsyncCallback } callback - The callback is used to return the OperationType of the WantAgent. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getOperationType(agent: WantAgent, callback: AsyncCallback): void; + + /** + * Obtains the {@link OperationType} of a {@link WantAgent}. + * @param { WantAgent } agent - Indicates the WantAgent. + * @returns { Promise } Returns the OperationType of the WantAgent. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + function getOperationType(agent: WantAgent): Promise; + + /** + * Enumerates flags for using a WantAgent. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + 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. + * @enum { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + 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. + * @typedef CompleteData + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export interface CompleteData { + /** + * Triggered WantAgent. + * @type { WantAgent } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + info: WantAgent; + + /** + * Existing Want that is triggered. + * @type { Want } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + want: Want; + + /** + * Request code used to trigger the WantAgent. + * @type { number } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + finalCode: number; + + /** + * Final data collected by the common event. + * @type { string } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + finalData: string; + + /** + * Extra data collected by the common event. + * @type { { [key: string]: any } } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + extraInfo?: { [key: string]: any }; + } + + /** + * Provides the information required for triggering a WantAgent. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type TriggerInfo = _TriggerInfo + + /** + * Provides the information required for triggering a WantAgent. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + export type WantAgentInfo = _WantAgentInfo +} + +/** + * WantAgent object. + */ +export type WantAgent = object; + +export default wantAgent; diff --git a/api/@ohos.app.ability.wantConstant.d.ts b/api/@ohos.app.ability.wantConstant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..05e563cd9f72d0d1db14468f5ddcf6fe2ea0eaa5 --- /dev/null +++ b/api/@ohos.app.ability.wantConstant.d.ts @@ -0,0 +1,439 @@ +/* + * 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 constant for action and entity in the want + * @namespace wantConstant + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ +declare namespace wantConstant { + /** + * the constant for action of the want + * @enum { string } + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + export enum Action { + /** + * Indicates the action of backing home. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_HOME = "ohos.want.action.home", + + /** + * Indicates the action of starting a Page ability that displays a keypad. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_DIAL = "ohos.want.action.dial", + + /** + * Indicates the action of starting a Page ability for search. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SEARCH = "ohos.want.action.search", + + /** + * Indicates the action of starting a Page ability that provides wireless network settings, for example, + * Wi-Fi options. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_WIRELESS_SETTINGS = "ohos.settings.wireless", + + /** + * Indicates the action of starting a Page ability that manages installed applications. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + 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. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_APPLICATION_DETAILS_SETTINGS = "ohos.settings.application.details", + + /** + * Indicates the action of starting a Page ability for setting an alarm clock. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SET_ALARM = "ohos.want.action.setAlarm", + + /** + * Indicates the action of starting a Page ability that displays all alarm + * clocks. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SHOW_ALARMS = "ohos.want.action.showAlarms", + + /** + * Indicates the action of starting a Page ability for snoozing an alarm clock. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SNOOZE_ALARM = "ohos.want.action.snoozeAlarm", + + /** + * Indicates the action of starting a Page ability for deleting an alarm clock. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_DISMISS_ALARM = "ohos.want.action.dismissAlarm", + + /** + * Indicates the action of starting a Page ability for dismissing a timer. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_DISMISS_TIMER = "ohos.want.action.dismissTimer", + + /** + * Indicates the action of starting a Page ability for sending a sms. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SEND_SMS = "ohos.want.action.sendSms", + + /** + * Indicates the action of starting a Page ability for opening contacts or pictures. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_CHOOSE = "ohos.want.action.choose", + + /** + * Indicates the action of starting a Page ability for take a picture. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_IMAGE_CAPTURE = "ohos.want.action.imageCapture", + + /** + * Indicates the action of starting a Page ability for Take a video. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_VIDEO_CAPTURE = "ohos.want.action.videoCapture", + + /** + * Indicates the action of showing the application selection dialog box. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SELECT = "ohos.want.action.select", + + /** + * Indicates the action of sending a single data record. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SEND_DATA = "ohos.want.action.sendData", + + /** + * Indicates the action of sending multiple data records. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + 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. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_SCAN_MEDIA_FILE = "ohos.want.action.scanMediaFile", + + /** + * Indicates the action of viewing data. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_VIEW_DATA = "ohos.want.action.viewData", + + /** + * Indicates the action of editing data. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_EDIT_DATA = "ohos.want.action.editData", + + /** + * Indicates the choices you will show with {@link #ACTION_PICKER}. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + INTENT_PARAMS_INTENT = "ability.want.params.INTENT", + + /** + * Indicates the CharSequence dialog title when used with a {@link #ACTION_PICKER}. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + INTENT_PARAMS_TITLE = "ability.want.params.TITLE", + + /** + * Indicates the action of select file. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + 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}. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + PARAMS_STREAM = "ability.params.stream", + + /** + * Indicates the action of providing auth service. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ACTION_APP_ACCOUNT_AUTH = "account.appAccount.action.auth", + + /** + * Indicates the action of an application downloaded from the application market. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + ACTION_MARKET_DOWNLOAD = "ohos.want.action.marketDownload", + + /** + * Indicates the action of an application crowdtested from the application market. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + ACTION_MARKET_CROWDTEST = "ohos.want.action.marketCrowdTest", + + /** + * Indicates the param of sandbox flag. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox", + + /** + * Indicates the param of dlp bundle name. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + DLP_PARAMS_BUNDLE_NAME = "ohos.dlp.params.bundleName", + + /** + * Indicates the param of dlp module name. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + DLP_PARAMS_MODULE_NAME = "ohos.dlp.params.moduleName", + + /** + * Indicates the param of dlp ability name. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + DLP_PARAMS_ABILITY_NAME = "ohos.dlp.params.abilityName", + + /** + * Indicates the param of dlp bundle index. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + DLP_PARAMS_INDEX = "ohos.dlp.params.index" + } + + /** + * the constant for Entity of the want + * @enum { string } + * @name Entity + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + export enum Entity { + /** + * Indicates the default entity, which is used if the entity is not specified. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ENTITY_DEFAULT = "entity.system.default", + + /** + * Indicates the home screen entity. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ENTITY_HOME = "entity.system.home", + + /** + * Indicates the voice interaction entity. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ENTITY_VOICE = "entity.system.voice", + + /** + * Indicates the browser category. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ENTITY_BROWSABLE = "entity.system.browsable", + + /** + * Indicates the video category. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + ENTITY_VIDEO = "entity.system.video" + } + + export enum Flags { + /** + * Indicates the grant to perform read operations on the URI. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_AUTH_READ_URI_PERMISSION = 0x00000001, + + /** + * Indicates the grant to perform write operations on the URI. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_AUTH_WRITE_URI_PERMISSION = 0x00000002, + + /** + * Returns the result to the source ability. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_ABILITY_FORWARD_RESULT = 0x00000004, + + /** + * Determines whether an ability on the local device can be migrated to a remote device. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_ABILITY_CONTINUATION = 0x00000008, + + /** + * Specifies whether a component does not belong to OHOS. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_NOT_OHOS_COMPONENT = 0x00000010, + + /** + * Specifies whether an ability is started. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_ABILITY_FORM_ENABLED = 0x00000020, + + /** + * Indicates the grant for possible persisting on the URI. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + FLAG_AUTH_PERSISTABLE_URI_PERMISSION = 0x00000040, + + /** + * Returns the result to the source ability slice. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + FLAG_AUTH_PREFIX_URI_PERMISSION = 0x00000080, + + /** + * Supports multi-device startup in the distributed scheduling system. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_ABILITYSLICE_MULTI_DEVICE = 0x00000100, + + /** + * Indicates that an ability using the Service template is started regardless of whether the host application has + * been started. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_START_FOREGROUND_ABILITY = 0x00000200, + + /** + * Indicates the continuation is reversible. + * @syscap SystemCapability.Ability.AbilityBase + * @systemapi + * @since 9 + */ + FLAG_ABILITY_CONTINUATION_REVERSIBLE = 0x00000400, + + /** + * Install the specified ability if it's not installed. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_INSTALL_ON_DEMAND = 0x00000800, + + /** + * Install the specifiedi ability with background mode if it's not installed. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + 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}. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_ABILITY_CLEAR_MISSION = 0x00008000, + + /** + * Indicates the operation of creating a task on the historical mission stack. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + 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. + * @syscap SystemCapability.Ability.AbilityBase + * @since 9 + */ + FLAG_ABILITY_MISSION_TOP = 0x20000000 + } +} + +export default wantConstant; diff --git a/api/@ohos.app.form.FormExtensionAbility.d.ts b/api/@ohos.app.form.FormExtensionAbility.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aeed2002d1196653393922c27658130ee075a84c --- /dev/null +++ b/api/@ohos.app.form.FormExtensionAbility.d.ts @@ -0,0 +1,138 @@ +/* + * 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.app.form.formBindingData'; +import formInfo from "./@ohos.app.form.formInfo"; +import FormExtensionContext from "./application/FormExtensionContext"; +import Want from './@ohos.app.ability.Want'; +import { Configuration } from './@ohos.app.ability.Configuration'; + +/** + * class of form extension. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ +export default class FormExtensionAbility { + /** + * Indicates form extension context. + * @type { FormExtensionContext } + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + context: FormExtensionContext; + + /** + * Called to return a {@link formBindingData#FormBindingData} object. + * @param { Want } 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 { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onAddForm(want: Want): formBindingData.FormBindingData; + + /** + * Called when the form provider is notified that a temporary form is successfully converted to a normal form. + * @param { string } formId - Indicates the ID of the form. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onCastToNormalForm(formId: string): void; + + /** + * Called to notify the form provider to update a specified form. + * @param { string } formId - Indicates the ID of the form to update. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onUpdateForm(formId: string): void; + + /** + * Called when the form provider receives form events from the system. + * @param { { [key: string]: number } } 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. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onChangeFormVisibility(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. + * @param { string } 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 { string } 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. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onFormEvent(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. + * @param { string } formId - Indicates the ID of the destroyed form. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onRemoveForm(formId: string): void; + + /** + * Called when the system configuration is updated. + * @param { Configuration } newConfig - Indicates the system configuration, such as language and color mode. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onConfigurationUpdate(newConfig: 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.

          + * @param { Want } 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 { formInfo.FormState } Returns the {@link formInfo#FormState} object. + * @syscap SystemCapability.Ability.Form + * @stagemodelonly + * @since 9 + */ + onAcquireFormState?(want: Want): formInfo.FormState; + + /** + * Called when the system shares the form. + * @param { string } formId - Indicates the ID of the form. + * @return { { [key: string]: any } } Returns the wantParams object. + * @syscap SystemCapability.Ability.Form + * @systemapi + * @stagemodelonly + * @since 9 + */ + onShareForm?(formId: string): { [key: string]: any }; +} diff --git a/api/@ohos.app.form.formHost.d.ts b/api/@ohos.app.form.formHost.d.ts index 4e066920eb4431adadb9b56d4489e516ec58bee8..96d204f779240bf6004b80f7a28d00bab714a0ec 100644 --- a/api/@ohos.app.form.formHost.d.ts +++ b/api/@ohos.app.form.formHost.d.ts @@ -15,8 +15,8 @@ import { AsyncCallback } from "./basic"; import { Callback } from "./basic"; -import Want from './@ohos.application.Want'; -import formInfo from './@ohos.application.formInfo' +import Want from './@ohos.app.ability.Want'; +import formInfo from './@ohos.app.form.formInfo'; /** * Interface of formHost. @@ -137,13 +137,13 @@ declare namespace formHost { * Converts a specified temporary form that has been obtained by the application into a normal form. * @permission ohos.permission.REQUIRE_FORM * @param { string } formId - Indicates the ID of the temporary form to convert. - * @param { AsyncCallback } callback - The callback of castTempForm. + * @param { AsyncCallback } callback - The callback of castToNormalForm. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.Form * @systemapi * @since 9 */ - function castTempForm(formId: string, callback: AsyncCallback): void; + function castToNormalForm(formId: string, callback: AsyncCallback): void; /** * Converts a specified temporary form that has been obtained by the application into a normal form. @@ -155,7 +155,7 @@ declare namespace formHost { * @systemapi * @since 9 */ - function castTempForm(formId: string): Promise; + function castToNormalForm(formId: string): Promise; /** * Sends a notification to the form framework to make the specified forms visible. @@ -490,13 +490,50 @@ declare namespace formHost { * @param { string } formId - Indicates the form ID. * @param { string } deviceId - Indicates the remote device ID. * @param { AsyncCallback } callback - The callback of shareForm. - * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.Form * @systemapi * @since 9 */ function shareForm(formId: string, deviceId: string, callback: AsyncCallback): void; + + /** + * Share form by formId and deviceId. + * @permission ohos.permission.REQUIRE_FORM and ohos.permission.DISTRIBUTED_DATASYNC + * @param { string } formId - Indicates the form ID. + * @param { string } deviceId - Indicates the remote device ID. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.Form + * @systemapi + * @since 9 + */ function shareForm(formId: string, deviceId: string): Promise; + + /** + * Notify form that privacy whether to be protected. + * @permission ohos.permission.REQUIRE_FORM. + * @param { Array } formIds - Indicates the specified form id. + * @param { boolean } isProtected - Indicates whether to be protected. + * @param { AsyncCallback } callback - The callback of notifyFormsPrivacyProtected. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.Form + * @systemapi + * @since 9 + */ + function notifyFormsPrivacyProtected(formIds: Array, isProtected: boolean, callback: AsyncCallback): void; + + /** + * Notify form that privacy whether to be protected. + * @permission ohos.permission.REQUIRE_FORM. + * @param { Array } formIds - Indicates the specified form id. + * @param { boolean } isProtected - Indicates whether to be protected. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.Form + * @systemapi + * @since 9 + */ + function notifyFormsPrivacyProtected(formIds: Array, isProtected: boolean): Promise; } export default formHost; \ No newline at end of file diff --git a/api/@ohos.app.form.formInfo.d.ts b/api/@ohos.app.form.formInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d075eb7b8980a1feeb320d6a3b4f259e9a5d8680 --- /dev/null +++ b/api/@ohos.app.form.formInfo.d.ts @@ -0,0 +1,486 @@ +/* + * 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.app.ability.Want'; + +/** + * interface of formInfo. + * @namespace formInfo + * @syscap SystemCapability.Ability.Form + * @since 9 + */ +declare namespace formInfo { + /** + * Provides information about a form. + * @typedef FormInfo + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + interface FormInfo { + /** + * Obtains the bundle name of the application to which this form belongs. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + bundleName: string; + + /** + * Obtains the name of the application module to which this form belongs. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + moduleName: string; + + /** + * Obtains the class name of the ability to which this form belongs. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + abilityName: string; + + /** + * Obtains the name of this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + name: string; + + /** + * Obtains the name of this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + description: string; + + /** + * Obtains the type of this form. Currently, JS forms are supported. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + type: FormType; + + /** + * Obtains the JS component name of this JS form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + jsComponentName: string; + + /** + * Obtains the color mode of this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + colorMode: ColorMode; + + /** + * Checks whether this form is a default form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + isDefault: boolean; + + /** + * Obtains the updateEnabled. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + updateEnabled: boolean; + + /** + * Obtains whether notify visible of this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + formVisibleNotify: boolean; + + /** + * Obtains the bundle relatedBundleName of the application to which this form belongs. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + relatedBundleName: string; + + /** + * Obtains the scheduledUpdateTime. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + scheduledUpdateTime: string; + + /** + * Obtains the form config ability about this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + formConfigAbility: string; + + /** + * Obtains the updateDuration. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + updateDuration: number; + + /** + * Obtains the default grid style of this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + defaultDimension: number; + + /** + * Obtains the grid styles supported by this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + supportDimensions: Array; + + /** + * Obtains the custom data defined in this form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + customizeData: {[key: string]: [value: string]}; + } + + /** + * Type of form. + * @enum { number } + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + enum FormType { + /** + * JS form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + JS = 1, + + /** + * eTS form. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + eTS = 2 + } + + /** + * Color mode. + * @enum { number } + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + enum ColorMode { + /** + * Automatic mode. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + MODE_AUTO = -1, + + /** + * Dark mode. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + MODE_DARK = 0, + + /** + * Light mode. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + MODE_LIGHT = 1 + } + + /** + * Provides state information about a form. + * @typedef FormStateInfo + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + interface FormStateInfo { + /** + * Obtains the form state. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + formState: FormState; + + /** + * Obtains the want form . + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + want: Want; + } + + /** + * Provides state about a form. + * @enum { number } + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + enum FormState { + /** + * Indicates that the form status is unknown due to an internal error. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + UNKNOWN = -1, + + /** + * Indicates that the form is in the default state. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + DEFAULT = 0, + + /** + * Indicates that the form is ready. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + READY = 1, + } + + /** + * Parameter of form. + * @enum { string } + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + enum FormParam { + /** + * Indicates the key specifying the ID of the form to be obtained, which is represented as + * want: { + * "parameters": { + * IDENTITY_KEY: "119476135" + * } + * }. + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + IDENTITY_KEY = "ohos.extra.param.key.form_identity", + + /** + * Indicates the key specifying the grid style of the form to be obtained, which is represented as + * want: { + * "parameters": { + * DIMENSION_KEY: FormDimension.Dimension_1_2 + * } + * }. + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + 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" + * } + * }. + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + 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. + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + 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 + * } + * } + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + 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 + * } + * } + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + 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 + * } + * } + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + TEMPORARY_KEY = "ohos.extra.param.key.form_temporary", + + /** + * Indicates the key specifying the name of the bundle to be obtained, which is represented as + * want: { + * "parameters": { + * BUNDLE_NAME_KEY: "bundleName" + * } + * } + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + BUNDLE_NAME_KEY = "ohos.extra.param.key.bundle_name", + + /** + * Indicates the key specifying the name of the ability to be obtained, which is represented as + * want: { + * "parameters": { + * ABILITY_NAME_KEY: "abilityName" + * } + * } + * + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + ABILITY_NAME_KEY = "ohos.extra.param.key.ability_name", + + /** + * Indicates the key specifying the the device ID, which is represented as + * want: { + * "parameters": { + * DEVICE_ID_KEY : "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2" + * } + * } + * + * @syscap SystemCapability.Ability.Form + * @systemapi + * @since 9 + */ + DEVICE_ID_KEY = "ohos.extra.param.key.device_id" + } + + /** + * The optional options used as filters to ask + * getFormsInfo to return formInfos from only forms that match the options. + * @typedef FormInfoFilter + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + interface FormInfoFilter { + /** + * optional moduleName that used to ask getFormsInfo to return + * form infos with the same moduleName. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + moduleName?: string; + } + + /** + * Defines the FormDimension enum. + * @enum { number } + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + enum FormDimension { + /** + * 1 x 2 form + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + Dimension_1_2 = 1, + + /** + * 2 x 2 form + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + Dimension_2_2, + + /** + * 2 x 4 form + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + Dimension_2_4, + + /** + * 4 x 4 form + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + Dimension_4_4, + + /** + * 2 x 1 form + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + Dimension_2_1, + } + /** + * The visibility of a form. + * @enum { number } + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + enum VisibilityType { + /** + * Indicates the type of the form is visible. + * Often used as a condition variable in function OnVisibilityChange to specify actions only on forms that are + * changing to visible. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + FORM_VISIBLE = 1, + /** + * Indicates the type of the form is invisible. + * Often used as a condition variable in function OnVisibilityChange to specify actions only on forms that are + * changing to invisible. + * @syscap SystemCapability.Ability.Form + * @since 9 + */ + FORM_INVISIBLE, + } +} +export default formInfo; \ No newline at end of file diff --git a/api/@ohos.app.form.formProvider.d.ts b/api/@ohos.app.form.formProvider.d.ts index f2a87e039e76e711005d86f00afb4dffcad483b8..31b048c78337ba2b85652aae4e58552c11f906eb 100644 --- a/api/@ohos.app.form.formProvider.d.ts +++ b/api/@ohos.app.form.formProvider.d.ts @@ -15,8 +15,8 @@ import { AsyncCallback } from "./basic"; import formBindingData from "./@ohos.app.form.formBindingData"; -import formInfo from "./@ohos.application.formInfo"; -import Want from "./@ohos.application.Want" +import formInfo from "./@ohos.app.form.formInfo"; +import Want from "./@ohos.app.ability.Want"; /** * Interface of formProvider. diff --git a/api/@ohos.application.Ability.d.ts b/api/@ohos.application.Ability.d.ts old mode 100755 new mode 100644 index 99cfd355610983da6d601b990f88caef60734b66..2a7fd56303250fe6aa36649340ffe327ef3b2b40 --- a/api/@ohos.application.Ability.d.ts +++ b/api/@ohos.application.Ability.d.ts @@ -29,6 +29,8 @@ import rpc from './@ohos.rpc'; * @param msg Monitor status notification information. * @return - * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.UIAbility */ export interface OnReleaseCallBack { (msg: string): void; @@ -43,6 +45,8 @@ export interface OnReleaseCallBack { * @param indata Notification data notified from the caller. * @return rpc.Sequenceable * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.UIAbility */ export interface CalleeCallBack { (indata: rpc.MessageParcel): rpc.Sequenceable; @@ -55,6 +59,8 @@ export interface CalleeCallBack { * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore * @permission N/A * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.UIAbility */ export interface Caller { /** @@ -110,6 +116,8 @@ export interface Caller { * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore * @permission N/A * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.UIAbility */ export interface Callee { @@ -144,6 +152,8 @@ export interface Callee { * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore * @permission N/A * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.UIAbility */ export default class Ability { /** @@ -314,4 +324,16 @@ export default class Ability { * @StageModelOnly */ onMemoryLevel(level: AbilityConstant.MemoryLevel): void; + + /** + * Called back when an ability prepares to save. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param reason state type when save. + * @param wantParam Indicates the want parameter. + * @return 0 if ability agrees to save data successfully, otherwise errcode. + * @StageModelOnly + */ + onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult; } diff --git a/api/@ohos.application.AbilityConstant.d.ts b/api/@ohos.application.AbilityConstant.d.ts index 2847a26649da5ad1cd18755a44126c049512fb47..de8f4b4979e1199a1b8a60a5228f62da27309d36 100644 --- a/api/@ohos.application.AbilityConstant.d.ts +++ b/api/@ohos.application.AbilityConstant.d.ts @@ -20,6 +20,8 @@ * @syscap SystemCapability.Ability.AbilityRuntime.Core * @permission N/A * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.AbilityConstant */ declare namespace AbilityConstant { /** @@ -61,6 +63,7 @@ declare namespace AbilityConstant { START_ABILITY = 1, CALL = 2, CONTINUATION = 3, + APP_RECOVERY = 4, } /** @@ -116,6 +119,34 @@ declare namespace AbilityConstant { WINDOW_MODE_SPLIT_SECONDARY = 101, WINDOW_MODE_FLOATING = 102, } + + /** + * Type of onSave result. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum OnSaveResult { + ALL_AGREE = 0, + CONTINUATION_REJECT = 1, + CONTINUATION_MISMATCH = 2, + RECOVERY_AGREE = 3, + RECOVERY_REJECT = 4, + ALL_REJECT, + } + + /** + * Type of save state. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ + export enum StateType { + CONTINUATION = 0, + APP_RECOVERY = 1, + } } export default AbilityConstant diff --git a/api/@ohos.application.AbilityLifecycleCallback.d.ts b/api/@ohos.application.AbilityLifecycleCallback.d.ts index 33db234da5362cd83e943d739ec29e5eb86d02dd..4e1f22ac9c3d3528091f2325a41d6da4514045c1 100644 --- a/api/@ohos.application.AbilityLifecycleCallback.d.ts +++ b/api/@ohos.application.AbilityLifecycleCallback.d.ts @@ -23,6 +23,8 @@ import window from './@ohos.window'; * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.AbilityLifecycleCallback */ export default class AbilityLifecycleCallback { /** diff --git a/api/@ohos.application.AbilityStage.d.ts b/api/@ohos.application.AbilityStage.d.ts index a0369329ced0b6fd370c0dba7f70721357ac2e33..8d7b4cc1c8180a13903434f6e8719310a01d654e 100644 --- a/api/@ohos.application.AbilityStage.d.ts +++ b/api/@ohos.application.AbilityStage.d.ts @@ -25,6 +25,8 @@ import { Configuration } from './@ohos.application.Configuration'; * @syscap SystemCapability.Ability.AbilityRuntime.Core * @permission N/A * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.AbilityStage */ export default class AbilityStage { /** diff --git a/api/@ohos.application.Configuration.d.ts b/api/@ohos.application.Configuration.d.ts index b1c3861169ad7dcd36bd1e5e1940b4cfc8228cb6..2d339a39400374a1178cb4e08795ad856cd794c6 100644 --- a/api/@ohos.application.Configuration.d.ts +++ b/api/@ohos.application.Configuration.d.ts @@ -22,6 +22,8 @@ import ConfigurationConstant from "./@ohos.application.ConfigurationConstant"; * @since 8 * @syscap SystemCapability.Ability.AbilityBase * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.Configuration */ export interface Configuration { /** diff --git a/api/@ohos.application.ConfigurationConstant.d.ts b/api/@ohos.application.ConfigurationConstant.d.ts index cdf3b32724869aa6705e85d53a58b7dddbff196f..7e3853aa5d8abc9dd362264bc2c0843a7eb48e20 100644 --- a/api/@ohos.application.ConfigurationConstant.d.ts +++ b/api/@ohos.application.ConfigurationConstant.d.ts @@ -19,6 +19,8 @@ * @since 8 * @syscap SystemCapability.Ability.AbilityBase * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.ConfigurationConstant */ declare namespace ConfigurationConstant { /** diff --git a/api/@ohos.application.EnvironmentCallback.d.ts b/api/@ohos.application.EnvironmentCallback.d.ts index b19bd5792eff52fc21ea06e0d6501cf543ba9f7c..55f6504a703c7fb597ea521be36d6df177ab16d4 100755 --- a/api/@ohos.application.EnvironmentCallback.d.ts +++ b/api/@ohos.application.EnvironmentCallback.d.ts @@ -21,6 +21,8 @@ import { Configuration } from './@ohos.application.Configuration'; * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.EnvironmentCallback */ export default class EnvironmentCallback { /** diff --git a/api/@ohos.application.ExtensionAbility.d.ts b/api/@ohos.application.ExtensionAbility.d.ts index 3cfd0d921354adae992e94462b2adb463e8b5dc4..eda81a8ac3c5ace16928b4a04e0072336177b684 100644 --- a/api/@ohos.application.ExtensionAbility.d.ts +++ b/api/@ohos.application.ExtensionAbility.d.ts @@ -22,6 +22,8 @@ import { Configuration } from './@ohos.application.Configuration'; * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.ExtensionAbility */ export default class ExtensionAbility { /** diff --git a/api/@ohos.application.FormExtension.d.ts b/api/@ohos.application.FormExtension.d.ts index 4c52a8387e5b8fe5d5cde711b3f72c6d13f698cf..e3bbfc7fdc0aaba3789c923bb11e05214329e07e 100644 --- a/api/@ohos.application.FormExtension.d.ts +++ b/api/@ohos.application.FormExtension.d.ts @@ -25,6 +25,8 @@ import { Configuration } from './@ohos.application.Configuration'; * @since 9 * @syscap SystemCapability.Ability.Form * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.form.FormExtensionAbility */ export default class FormExtension { /** diff --git a/api/@ohos.application.ServiceExtensionAbility.d.ts b/api/@ohos.application.ServiceExtensionAbility.d.ts index 9b7e74eb470afa71b6dad5910c8255d029a9c3a1..5b850b90f6fde5f4dd8e9c491e93e6e1161d96a7 100644 --- a/api/@ohos.application.ServiceExtensionAbility.d.ts +++ b/api/@ohos.application.ServiceExtensionAbility.d.ts @@ -25,6 +25,8 @@ import { Configuration } from './@ohos.application.Configuration'; * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi hide for inner use. * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.ServiceExtensionAbility */ export default class ServiceExtensionAbility { /** diff --git a/api/@ohos.application.StartOptions.d.ts b/api/@ohos.application.StartOptions.d.ts index b4cd41bbceab5748d8c933e5331f968ec393817e..0fc112e6d91d9097b515f98c4d9ebb8e760bfc79 100644 --- a/api/@ohos.application.StartOptions.d.ts +++ b/api/@ohos.application.StartOptions.d.ts @@ -21,6 +21,8 @@ * @syscap SystemCapability.Ability.AbilityRuntime.Core * @permission N/A * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.StartOptions */ export default class StartOptions { /** diff --git a/api/@ohos.application.Want.d.ts b/api/@ohos.application.Want.d.ts index 1a54ebefd9e6dd0cff0c86d9681044c0147318b1..b417aba928315badd9a3438d4c36c03f10c962e8 100644 --- a/api/@ohos.application.Want.d.ts +++ b/api/@ohos.application.Want.d.ts @@ -20,6 +20,8 @@ * @since 8 * @syscap SystemCapability.Ability.AbilityBase * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.Want */ export default class Want { /** diff --git a/api/@ohos.application.abilityDelegatorRegistry.d.ts b/api/@ohos.application.abilityDelegatorRegistry.d.ts index ad936320c56840c0517b6d5d55d041aab539644d..d8d7a51a5b03418ae8a3542a5ea6d937bec1d50e 100644 --- a/api/@ohos.application.abilityDelegatorRegistry.d.ts +++ b/api/@ohos.application.abilityDelegatorRegistry.d.ts @@ -26,6 +26,8 @@ import { ShellCmdResult as _ShellCmdResult } from './application/shellCmdResult' * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.abilityDelegatorRegistry */ declare namespace abilityDelegatorRegistry { /** diff --git a/api/@ohos.application.abilityManager.d.ts b/api/@ohos.application.abilityManager.d.ts index a35eebd58311a8ce2ebcd8102ae9b4c09abf6649..dfa26ab42bde00f254c423fa7173ae4d5699ab03 100644 --- a/api/@ohos.application.abilityManager.d.ts +++ b/api/@ohos.application.abilityManager.d.ts @@ -26,6 +26,8 @@ import { ElementName } from './bundle/elementName'; * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi Hide this for inner system use * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.abilityManager */ declare namespace abilityManager { /** diff --git a/api/@ohos.application.appManager.d.ts b/api/@ohos.application.appManager.d.ts index 834a8ef58d767279399e56eec2936495cedce034..3be17cb2018657e9bfc5176c48ec62083604d6ef 100644 --- a/api/@ohos.application.appManager.d.ts +++ b/api/@ohos.application.appManager.d.ts @@ -27,6 +27,8 @@ import { ProcessRunningInformation as _ProcessRunningInformation } from './appli * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import appManager from '@ohos.application.appManager' * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.appManager */ declare namespace appManager { /** diff --git a/api/@ohos.application.context.d.ts b/api/@ohos.application.context.d.ts index cae84c127a276814734bf67b0dca81780e7a3d09..da1ee4f905a2d0e2319a4a3bd9c3d42f336f0c92 100755 --- a/api/@ohos.application.context.d.ts +++ b/api/@ohos.application.context.d.ts @@ -29,6 +29,8 @@ import * as _PermissionRequestResult from './application/PermissionRequestResul * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly + * @deprecated since 9 + * @useinstead ohos.app.ability.common */ declare namespace context { @@ -97,24 +99,6 @@ declare namespace context { */ export type FormExtensionContext = _FormExtensionContext.default - /** - * 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 - } - /** * The event center of a context, support the subscription and publication of events. * diff --git a/api/@ohos.application.errorManager.d.ts b/api/@ohos.application.errorManager.d.ts index dda4361c792b435dc9a79088111180181cbd6216..1709d8e029dd08871acc5ea349c37bb483d91d0e 100644 --- a/api/@ohos.application.errorManager.d.ts +++ b/api/@ohos.application.errorManager.d.ts @@ -23,6 +23,8 @@ import * as _ErrorObserver from './application/ErrorObserver'; * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import errorManager from '@ohos.application.errorManager' * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.errorManager */ declare namespace errorManager { /** diff --git a/api/@ohos.application.formInfo.d.ts b/api/@ohos.application.formInfo.d.ts index 46c60e52744dacff91de00ec1ec7d58cabe75a3b..c1fef018f8b77fa3ef12de1ac626b9a5312eeaab 100644 --- a/api/@ohos.application.formInfo.d.ts +++ b/api/@ohos.application.formInfo.d.ts @@ -21,6 +21,8 @@ import Want from './@ohos.application.Want'; * @name formInfo * @since 8 * @syscap SystemCapability.Ability.Form + * @deprecated since 9 + * @useinstead ohos.app.form.formInfo */ declare namespace formInfo { /** @@ -190,7 +192,15 @@ declare namespace formInfo { * @since 8 * @syscap SystemCapability.Ability.Form */ - JS = 1 + JS = 1, + + /** + * eTS form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + eTS = 2 } /** @@ -501,21 +511,21 @@ declare namespace formInfo { * @since 9 * @syscap SystemCapability.Ability.Form */ - interface VisibilityType { + enum VisibilityType { /** * Indicates the type of the form is visible. - * Often used as a condition variable in function OnVisibilityChanged() to specify actions only on forms that are + * Often used as a condition variable in function OnVisibilityChange() to specify actions only on forms that are * changing to visible. * @since 9 */ - FORM_VISIBLE: number, + FORM_VISIBLE = 1, /** * Indicates the type of the form is invisible. - * Often used as a condition variable in function OnVisibilityChanged() to specify actions only on forms that are + * Often used as a condition variable in function OnVisibilityChange() to specify actions only on forms that are * changing to invisible. * @since 9 */ - FORM_INVISIBLE: number + FORM_INVISIBLE, } } export default formInfo; \ No newline at end of file diff --git a/api/@ohos.application.missionManager.d.ts b/api/@ohos.application.missionManager.d.ts index 3f43e85ddc99b2646f8bb7b1cb80c07b05a882f0..46062f5f4255cfb4f78665164ddf8bfe53619241 100644 --- a/api/@ohos.application.missionManager.d.ts +++ b/api/@ohos.application.missionManager.d.ts @@ -27,6 +27,8 @@ import StartOptions from "./@ohos.application.StartOptions"; * @syscap SystemCapability.Ability.AbilityRuntime.Mission * @permission ohos.permission.MANAGE_MISSIONS * @systemapi hide for inner use. + * @deprecated since 9 + * @useinstead ohos.app.ability.missionManager */ declare namespace missionManager { /** diff --git a/api/@ohos.backgroundTaskManager.d.ts b/api/@ohos.backgroundTaskManager.d.ts index dc66d4f79d68e148c34118e041d5f82ac35b1042..7f10c8edb511470c338da775e53ec0008aa2c8b6 100644 --- a/api/@ohos.backgroundTaskManager.d.ts +++ b/api/@ohos.backgroundTaskManager.d.ts @@ -22,6 +22,8 @@ import Context from './application/BaseContext'; * * @since 7 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager */ declare namespace backgroundTaskManager { /** @@ -30,6 +32,8 @@ declare namespace backgroundTaskManager { * @name DelaySuspendInfo * @since 7 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.DelaySuspendInfo */ interface DelaySuspendInfo { /** @@ -48,6 +52,8 @@ declare namespace backgroundTaskManager { * @since 7 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask * @param requestId Indicates the identifier of the delay request. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.cancelSuspendDelay */ function cancelSuspendDelay(requestId: number): void; @@ -58,6 +64,8 @@ declare namespace backgroundTaskManager { * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask * @param requestId Indicates the identifier of the delay request. * @return The remaining delay time + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.getRemainingDelayTime */ function getRemainingDelayTime(requestId: number, callback: AsyncCallback): void; function getRemainingDelayTime(requestId: number): Promise; @@ -70,6 +78,8 @@ declare namespace backgroundTaskManager { * @param reason Indicates the reason for delayed transition to the suspended state. * @param callback The callback delay time expired. * @return Info of delay request + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.requestSuspendDelay */ function requestSuspendDelay(reason: string, callback: Callback): DelaySuspendInfo; @@ -83,6 +93,8 @@ declare namespace backgroundTaskManager { * @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. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.startBackgroundRunning */ function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback): void; function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise; @@ -93,34 +105,19 @@ declare namespace backgroundTaskManager { * @since 8 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask * @param context app running context. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.stopBackgroundRunning */ function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; function stopBackgroundRunning(context: Context): Promise; /** - * Apply or unapply efficiency resources. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @return True if efficiency resources apply success, else false. - * @systemapi Hide this for inner system use. - */ - function applyEfficiencyResources(request: EfficiencyResourcesRequest): boolean; - - /** - * Reset all efficiency resources apply. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @systemapi Hide this for inner system use. - */ - function resetAllEfficiencyResources(): void; - - /** - * supported background mode. + * Supported background mode. * * @since 8 * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @deprecated since 9 + * @useinstead ohos.resourceschedule.backgroundTaskManager.BackgroundMode */ export enum BackgroundMode { /** @@ -198,90 +195,6 @@ declare namespace backgroundTaskManager { */ TASK_KEEPING = 9, } - - /** - * The type of resource. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @systemapi Hide this for inner system use. - */ - export enum ResourceType { - /** - * The cpu resource for not being suspended. - */ - CPU = 1, - - /** - * The resource for not being proxyed common_event. - */ - COMMON_EVENT = 1 << 1, - - /** - * The resource for not being proxyed timer. - */ - TIMER = 1 << 2, - - /** - * The resource for not being proxyed workscheduler. - */ - WORK_SCHEDULER = 1 << 3, - - /** - * The resource for not being proxyed bluetooth. - */ - BLUETOOTH = 1 << 4, - - /** - * The resource for not being proxyed gps. - */ - GPS = 1 << 5, - - /** - * The resource for not being proxyed audio. - */ - AUDIO = 1 << 6 - } - - /** - * The request of efficiency resources. - * - * @name EfficiencyResourcesRequest - * @since 9 - * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply - * @systemapi Hide this for inner system use. - */ - export interface EfficiencyResourcesRequest { - /** - * The set of resource types that app wants to apply. - */ - resourceTypes: number; - - /** - * True if the app begin to use, else false. - */ - isApply: boolean; - - /** - * The duration that the resource can be used most. - */ - timeOut: number; - - /** - * True if the apply action is persist, else false. Default value is false. - */ - isPersist?: boolean; - - /** - * True if apply action is for process, false is for package. Default value is false. - */ - isProcess?: boolean; - - /** - * The apply reason. - */ - reason: string; - } } export default backgroundTaskManager; diff --git a/api/@ohos.batteryInfo.d.ts b/api/@ohos.batteryInfo.d.ts index 3a27e57498e94a60cd4ddeef9955d6320418b1ae..108844a7a13f82499b698e2396b6fd1bbfbe2641 100644 --- a/api/@ohos.batteryInfo.d.ts +++ b/api/@ohos.batteryInfo.d.ts @@ -241,7 +241,7 @@ declare namespace batteryInfo { } /** - * Etra key code of common event COMMON_EVENT_BATTERY_CHANGED. + * Extra key code of common event COMMON_EVENT_BATTERY_CHANGED. * * @syscap SystemCapability.PowerManager.BatteryManager.Core * @since 9 diff --git a/api/@ohos.batteryStatistics.d.ts b/api/@ohos.batteryStatistics.d.ts index 2af0b585edf9b146aefc712347f17068d347086c..a3b0b0531f36cdc49d1977523319d294e8136a13 100755 --- a/api/@ohos.batteryStatistics.d.ts +++ b/api/@ohos.batteryStatistics.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { AsyncCallback } from "./basic"; +import {AsyncCallback, BusinessError} from "./basic"; /** * Provides methods to get power consumption information. @@ -61,18 +61,28 @@ declare namespace batteryStats { /** * Obtains the power consumption information list. * - * @return Returns power consumption information list of a device. + * @return {Promise>} Power consumption information list. * @systemapi * @since 8 */ function getBatteryStats(): Promise>; + + /** + * Obtains the power consumption information list. + * + * @param {AsyncCallback} callback Indicates the callback of power consumption information list. + * @throws {BusinessError} 401 - If the callback is not valid. + * @systemapi + * @since 8 + */ function getBatteryStats(callback: AsyncCallback>): void; /** * Obtains power consumption information(Mah) for a given uid. * - * @param uid Indicates the uid. - * @return Returns power consumption information(Mah). + * @param {number} uid Indicates the uid. + * @return {number} Power consumption information(Mah). + * @throws {BusinessError} 4600101 - If connecting to the service failed. * @systemapi * @since 8 */ @@ -81,8 +91,9 @@ declare namespace batteryStats { /** * Obtains power consumption information(Percent) for a given uid. * - * @param uid Indicates the uid. - * @return Returns power consumption information(Percent). + * @param {number} uid Indicates the uid. + * @return {number} Power consumption information(Percent). + * @throws {BusinessError} 4600101 - If connecting to the service failed. * @systemapi * @since 8 */ @@ -91,8 +102,10 @@ declare namespace batteryStats { /** * Obtains power consumption information(Mah) for a given type. * - * @param ConsumptionType Indicates the hardware type. - * @return Returns power consumption information(Mah). + * @param {ConsumptionType} type Indicates the hardware type. + * @return {number} Power consumption information(Mah). + * @throws {BusinessError} 401 - If the type is not valid. + * @throws {BusinessError} 4600101 - If connecting to the service failed. * @systemapi * @since 8 */ @@ -101,8 +114,10 @@ declare namespace batteryStats { /** * Obtains power consumption information(Percent) for a given type. * - * @param ConsumptionType Indicates the hardware type. - * @return Returns power consumption information(Percent). + * @param {ConsumptionType} type Indicates the hardware type. + * @return {number} Power consumption information(Percent). + * @throws {BusinessError} 401 - If the type is not valid. + * @throws {BusinessError} 4600101 - If connecting to the service failed. * @systemapi * @since 8 */ diff --git a/api/@ohos.brightness.d.ts b/api/@ohos.brightness.d.ts index adb007cd2caa1996d525b861cac454b7a0137de9..ab8eec2b79966d52f5b3929fe5c78b99fcb9f613 100644 --- a/api/@ohos.brightness.d.ts +++ b/api/@ohos.brightness.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -13,7 +13,7 @@ * limitations under the License. */ -import { AsyncCallback } from './basic'; +import {BusinessError} from './basic'; /** * Provides interfaces to control the power of display. @@ -23,13 +23,15 @@ import { AsyncCallback } from './basic'; * @since 7 */ declare namespace brightness { - /** - * Sets the screen brightness. - * - * @param value Brightness value, ranging from 0 to 255. - * @systemapi - * @since 7 - */ - function setValue(value: number): void; + /** + * Sets the screen brightness. + * + * @param {number} value Brightness value, ranging from 0 to 255. + * @throws {BusinessError} 401 - If the value is not valid. + * @throws {BusinessError} 4700101 - If connecting to the service failed. + * @systemapi + * @since 7 + */ + function setValue(value: number): void; } export default brightness; diff --git a/api/@ohos.buffer.d.ts b/api/@ohos.buffer.d.ts index 3931a0aeaa132f260f13e734ba050ff121896529..d4ec693cfd897af04417ac3972bced92fe637ed4 100644 --- a/api/@ohos.buffer.d.ts +++ b/api/@ohos.buffer.d.ts @@ -1,6 +1,6 @@ /* * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (The type of "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -32,6 +32,7 @@ declare namespace buffer { * @param [fill=0] A value to pre-fill the new Buffer with * @param [encoding='utf8'] If `fill` is a string, this is its encoding * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer; @@ -41,6 +42,7 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param size The desired length of the new Buffer * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function allocUninitializedFromPool(size: number): Buffer; @@ -50,6 +52,7 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param size The desired length of the new Buffer * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function allocUninitialized(size: number): Buffer; @@ -62,6 +65,7 @@ declare namespace buffer { * @param string A value to calculate the length of * @param [encoding='utf8'] If `string` is a string, this is its encoding * @return The number of bytes contained within `string` + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function byteLength(string: string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number; @@ -72,6 +76,8 @@ declare namespace buffer { * @param list List of `Buffer` or Uint8Array instances to concatenate * @param totalLength Total length of the `Buffer` instances in `list` when concatenated * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "length" is out of range. It must be >= 0 and <= uint32 max. Received value is: [length] */ function concat(list: Buffer[] | Uint8Array[], totalLength?: number): Buffer; @@ -81,6 +87,7 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param array an array of bytes in the range 0 – 255 * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function from(array: number[]): Buffer; @@ -92,6 +99,8 @@ declare namespace buffer { * @param [byteOffset = 0] Index of first byte to expose * @param [length = arrayBuffer.byteLength - byteOffset] Number of bytes to expose * @return Return a view of the ArrayBuffer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[byteOffset/length]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [byteOffset/length] */ function from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; @@ -101,6 +110,7 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param buffer An existing Buffer or Uint8Array from which to copy data * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function from(buffer: Buffer | Uint8Array): Buffer; @@ -113,6 +123,7 @@ declare namespace buffer { * @param offsetOrEncoding A byte-offset or encoding * @param length A length * @return Return a new allocated Buffer + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function from(object: Object, offsetOrEncoding: number | string, length: number): Buffer; @@ -124,6 +135,7 @@ declare namespace buffer { * @param string A string to encode * @param [encoding='utf8'] The encoding of string * @return Return a new Buffer containing string + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function from(string: String, encoding?: BufferEncoding): Buffer; @@ -154,6 +166,7 @@ declare namespace buffer { * @return 0 is returned if target is the same as buf * 1 is returned if target should come before buf when sorted. * -1 is returned if target should come after buf when sorted. + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function compare(buf1: Buffer | Uint8Array, buf2: Buffer | Uint8Array): -1 | 0 | 1; @@ -165,6 +178,7 @@ declare namespace buffer { * @param fromEnc The current encoding * @param toEnc To target encoding * @return Returns a new Buffer instance + * @throws {BusinessError} 401 - if the input parameters are invalid. */ function transcode(source: Buffer | Uint8Array, fromEnc: string, toEnc: string): Buffer; @@ -176,20 +190,23 @@ declare namespace buffer { * Returns the number of bytes in buf * @since 9 * @syscap SystemCapability.Utils.Lang + * @throws {BusinessError} 10200013 - Cannot set property length of Buffer which has only a getter */ length: number; /** * The underlying ArrayBuffer object based on which this Buffer object is created. * @since 9 - * @syscap SystemCapability.Utils.Lang + * @syscap SystemCapability.Utils.Lang + * @throws {BusinessError} 10200013 - Cannot set property buffer of Buffer which has only a getter */ buffer: ArrayBuffer; /** * The byteOffset of the Buffers underlying ArrayBuffer object * @since 9 - * @syscap SystemCapability.Utils.Lang + * @syscap SystemCapability.Utils.Lang + * @throws {BusinessError} 10200013 - Cannot set property byteOffset of Buffer which has only a getter */ byteOffset: number; @@ -202,6 +219,8 @@ declare namespace buffer { * @param [end = buf.length] Where to stop filling buf (not inclusive) * @param [encoding='utf8'] The encoding for value if value is a string * @return A reference to buf + * @throws {BusinessError} 10200001 - The value of "[offset/end]" is out of range. It must be >= 0 and <= [right range]. Received value is: [offset/end] + * @throws {BusinessError} 401 - if the input parameters are invalid. */ fill(value: string | Buffer | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): Buffer; @@ -218,6 +237,9 @@ declare namespace buffer { * @return 0 is returned if target is the same as buf * 1 is returned if target should come before buf when sorted. * -1 is returned if target should come after buf when sorted. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[targetStart/targetEnd/sourceStart/sourceEnd]" is out of range. + * It must be >= 0 and <= [right range]. Received value is: [targetStart/targetEnd/sourceStart/sourceEnd] */ compare(target: Buffer | Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1; @@ -231,6 +253,9 @@ declare namespace buffer { * @param [sourceStart = 0] The offset within buf from which to begin copying * @param [sourceEnd = buf.length] The offset within buf at which to stop copying (not inclusive) * @return The number of bytes copied + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[targetStart/sourceStart/sourceEnd]" is out of range. It must be >= 0. + * Received value is: [targetStart/sourceStart/sourceEnd] */ copy(target: Buffer | Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; @@ -240,6 +265,7 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param otherBuffer A Buffer or Uint8Array with which to compare buf * @return true or false + * @throws {BusinessError} 401 - if the input parameters are invalid. */ equals(otherBuffer: Uint8Array | Buffer): boolean; @@ -251,6 +277,7 @@ declare namespace buffer { * @param [byteOffset = 0] Where to begin searching in buf. If negative, then offset is calculated from the end of buf * @param [encoding='utf8'] If value is a string, this is its encoding * @return true or false + * @throws {BusinessError} 401 - if the input parameters are invalid. */ includes(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean; @@ -262,6 +289,7 @@ declare namespace buffer { * @param [byteOffset = 0] Where to begin searching in buf * @param [encoding='utf8'] If value is a string, this is the encoding used to determine the binary representation of the string that will be searched for in buf * @return The index of the first occurrence of value in buf, or -1 if buf does not contain value + * @throws {BusinessError} 401 - if the input parameters are invalid. */ indexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; @@ -294,6 +322,7 @@ declare namespace buffer { * @param [byteOffset = 0] Where to begin searching in buf * @param [encoding='utf8'] If value is a string, this is the encoding used to determine the binary representation of the string that will be searched for in buf * @return The index of the last occurrence of value in buf, or -1 if buf does not contain value + * @throws {BusinessError} 401 - if the input parameters are invalid. */ lastIndexOf(value: string | number | Buffer | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number; @@ -303,6 +332,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @return Return a signed, big-endian 64-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ readBigInt64BE(offset?: number): bigint; @@ -311,7 +342,9 @@ declare namespace buffer { * @since 9 * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 - * @return Return a signed, little-endian 64-bit integer + * @return Return a signed, little-endian 64-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ readBigInt64LE(offset?: number): bigint; @@ -321,6 +354,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @return Return a unsigned, big-endian 64-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ readBigUInt64BE(offset?: number): bigint; @@ -330,6 +365,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @return Return a unsigned, little-endian 64-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ readBigUInt64LE(offset?: number): bigint; @@ -339,6 +376,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @return Return a 64-bit, big-endian double + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ readDoubleBE(offset?: number): number; @@ -348,6 +387,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 8 * @return Return a 64-bit, little-endian double + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ readDoubleLE(offset?: number): number; @@ -357,6 +398,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @return Return a 32-bit, big-endian float + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ readFloatBE(offset?: number): number; @@ -365,7 +408,9 @@ declare namespace buffer { * @since 9 * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 - * @return Return a 32-bit, little-endian float + * @return Return a 32-bit, little-endian float + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ readFloatLE(offset?: number): number; @@ -375,6 +420,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 1 * @return Return a signed 8-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 1. Received value is: [offset] */ readInt8(offset?: number): number; @@ -384,6 +431,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 2 * @return Return a signed, big-endian 16-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] */ readInt16BE(offset?: number): number; @@ -393,6 +442,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 2 * @return Return a signed, little-endian 16-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] */ readInt16LE(offset?: number): number; @@ -402,6 +453,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @return Return a signed, big-endian 32-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ readInt32BE(offset?: number): number; @@ -411,6 +464,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - 4 * @return Return a signed, little-endian 32-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ readInt32LE(offset?: number): number; @@ -422,6 +477,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @return + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ readIntBE(offset: number, byteLength: number): number; @@ -433,6 +490,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @return + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ readIntLE(offset: number, byteLength: number): number; @@ -442,6 +501,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 1 * @return Reads an unsigned 8-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 1. Received value is: [offset] */ readUInt8(offset?: number): number; @@ -451,6 +512,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2 * @return Reads an unsigned, big-endian 16-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] */ readUInt16BE(offset?: number): number; @@ -460,6 +523,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 2 * @return Reads an unsigned, little-endian 16-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 2. Received value is: [offset] */ readUInt16LE(offset?: number): number; @@ -469,6 +534,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4 * @return Reads an unsigned, big-endian 32-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ readUInt32BE(offset?: number): number; @@ -478,6 +545,8 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param [offset = 0] Number of bytes to skip before starting to read. Must satisfy 0 <= offset <= buf.length - 4 * @return Reads an unsigned, little-endian 32-bit integer + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ readUInt32LE(offset?: number): number; @@ -489,6 +558,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @return + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ readUIntBE(offset: number, byteLength: number): number; @@ -500,6 +571,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to read. Must satisfy: 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to read. Must satisfy 0 < byteLength <= 6 * @return + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ readUIntLE(offset: number, byteLength: number): number; @@ -518,6 +591,7 @@ declare namespace buffer { * @since 9 * @syscap SystemCapability.Utils.Lang * @return A reference to buf + * @throws {BusinessError} 10200009 - Buffer size must be a multiple of 16-bits */ swap16(): Buffer; @@ -526,6 +600,7 @@ declare namespace buffer { * @since 9 * @syscap SystemCapability.Utils.Lang * @return A reference to buf + * @throws {BusinessError} 10200009 - Buffer size must be a multiple of 32-bits */ swap32(): Buffer; @@ -534,6 +609,7 @@ declare namespace buffer { * @since 9 * @syscap SystemCapability.Utils.Lang * @return A reference to buf + * @throws {BusinessError} 10200009 - Buffer size must be a multiple of 64-bits */ swap64(): Buffer; @@ -552,6 +628,7 @@ declare namespace buffer { * @param [encoding='utf8'] The character encoding to use * @param [start = 0] The byte offset to start decoding at * @param [end = buf.length] The byte offset to stop decoding at (not inclusive) + * @throws {BusinessError} 401 - if the input parameters are invalid. */ toString(encoding?: string, start?: number, end?: number): string; @@ -564,6 +641,8 @@ declare namespace buffer { * @param [length = buf.length - offset] Maximum number of bytes to write (written bytes will not exceed buf.length - offset) * @param [encoding='utf8'] The character encoding of string. * @return Number of bytes written. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[offset/length]" is out of range. It must be >= 0 and <= buf.length. Received value is: [offset/length] */ write(str: string, offset?: number, length?: number, encoding?: string): number; @@ -574,6 +653,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeBigInt64BE(value: bigint, offset?: number): number; @@ -584,6 +665,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeBigInt64LE(value: bigint, offset?: number): number; @@ -594,6 +677,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeBigUInt64BE(value: bigint, offset?: number): number; @@ -603,7 +688,9 @@ declare namespace buffer { * @syscap SystemCapability.Utils.Lang * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 - * @return offset plus the number of bytes written + * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeBigUInt64LE(value: bigint, offset?: number): number; @@ -614,6 +701,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ writeDoubleBE(value: number, offset?: number): number; @@ -624,6 +713,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 8. Received value is: [offset] */ writeDoubleLE(value: number, offset?: number): number; @@ -634,6 +725,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ writeFloatBE(value: number, offset?: number): number; @@ -644,6 +737,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "offset" is out of range. It must be >= 0 and <= buf.length - 4. Received value is: [offset] */ writeFloatLE(value: number, offset?: number): number; @@ -652,8 +747,10 @@ declare namespace buffer { * @since 9 * @syscap SystemCapability.Utils.Lang * @param value Number to be written to buf - * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 8 + * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 1 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeInt8(value: number, offset?: number): number; @@ -664,6 +761,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 2 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeInt16BE(value: number, offset?: number): number; @@ -674,6 +773,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 2 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeInt16LE(value: number, offset?: number): number; @@ -684,6 +785,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeInt32BE(value: number, offset?: number): number; @@ -694,6 +797,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy: 0 <= offset <= buf.length - 4 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeInt32LE(value: number, offset?: number): number; @@ -705,6 +810,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeIntBE(value: number, offset: number, byteLength: number): number; @@ -716,6 +823,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeIntLE(value : number, offset: number, byteLength: number): number; @@ -726,6 +835,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 1 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUInt8(value: number, offset?: number): number; @@ -736,6 +847,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUInt16BE(value: number, offset?: number): number; @@ -746,6 +859,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 2 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUInt16LE(value: number, offset?: number): number; @@ -756,6 +871,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUInt32BE(value: number, offset?: number): number; @@ -766,6 +883,8 @@ declare namespace buffer { * @param value Number to be written to buf * @param [offset = 0] Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - 4 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUInt32LE(value: number, offset?: number): number; @@ -777,6 +896,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUIntBE(value: number, offset: number, byteLength: number): number; @@ -788,6 +909,8 @@ declare namespace buffer { * @param offset Number of bytes to skip before starting to write. Must satisfy 0 <= offset <= buf.length - byteLength * @param byteLength Number of bytes to write. Must satisfy 0 < byteLength <= 6 * @return offset plus the number of bytes written + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200001 - The value of "[param]" is out of range. It must be >= [left range] and <= [right range]. Received value is: [param] */ writeUIntLE(value: number, offset: number, byteLength: number): number; @@ -803,6 +926,7 @@ declare namespace buffer { * @param options {endings: string, type: string} * endings: One of either 'transparent' or 'native'. * type: The Blob content-type + * @throws {BusinessError} 401 - if the input parameters are invalid. */ constructor(sources: string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] , options?: Object); diff --git a/api/@ohos.bundle.appControl.d.ts b/api/@ohos.bundle.appControl.d.ts index 0f9de6b9fb14da9eef3bc40e8fd934153764207a..519affca68105cf23cea387f28f6b024bb41a314 100644 --- a/api/@ohos.bundle.appControl.d.ts +++ b/api/@ohos.bundle.appControl.d.ts @@ -14,7 +14,7 @@ */ import { AsyncCallback } from './basic'; -import Want from './@ohos.application.Want'; +import Want from './@ohos.app.ability.Want'; /** * Used for application interception control @@ -32,7 +32,7 @@ declare namespace appControl { * @param { AsyncCallback } callback - The callback of setting the disposed status result. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 801 - Capicity not supported. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700005 - The specified appId was not found. * @syscap SystemCapability.BundleManager.BundleFramework.AppControl * @systemapi @@ -48,7 +48,7 @@ declare namespace appControl { * @returns { Promise } The result of setting the disposed status of a specified bundle. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 801 - Capicity not supported. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700005 - The specified appId was not found. * @syscap SystemCapability.BundleManager.BundleFramework.AppControl * @systemapi @@ -63,7 +63,7 @@ declare namespace appControl { * @param { AsyncCallback } callback - The callback of getting the disposed status of a specified bundle result. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 801 - Capicity not supported. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700005 - The specified appId was not found. * @syscap SystemCapability.BundleManager.BundleFramework.AppControl * @systemapi @@ -78,7 +78,7 @@ declare namespace appControl { * @returns { Promise } Returns the disposed status of a specified bundle. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 801 - Capicity not supported. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700005 - The specified appId was not found. * @syscap SystemCapability.BundleManager.BundleFramework.AppControl * @systemapi @@ -93,7 +93,7 @@ declare namespace appControl { * @param { AsyncCallback } callback - the callback of deleting the disposed status of a specified bundle result. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 801 - Capicity not supported. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700005 - The specified appId was not found. * @syscap SystemCapability.BundleManager.BundleFramework.AppControl * @systemapi @@ -108,7 +108,7 @@ declare namespace appControl { * @returns { Promise } Returns the result of deleting the disposed status of a specified bundle. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 801 - Capicity not supported. + * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700005 - The specified appId was not found. * @syscap SystemCapability.BundleManager.BundleFramework.AppControl * @systemapi diff --git a/api/@ohos.bundle.bundleManager.d.ts b/api/@ohos.bundle.bundleManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..49c47e6b98d0f3de676813f864fbfbcb386a4cde --- /dev/null +++ b/api/@ohos.bundle.bundleManager.d.ts @@ -0,0 +1,1344 @@ +/* + * 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 { ApplicationInfo as _ApplicationInfo } from './bundleManager/applicationInfo'; +import { Metadata as _Metadata } from './bundleManager/metadata'; +import { HapModuleInfo as _HapModuleInfo } from './bundleManager/hapModuleInfo'; +import { PermissionDef as _PermissionDef } from './bundleManager/permissionDef'; +import { ElementName as _ElementName } from './bundleManager/elementName'; +import Want from './@ohos.app.ability.Want'; +import image from './@ohos.multimedia.image'; +import * as _AbilityInfo from './bundleManager/abilityInfo'; +import * as _BundleInfo from './bundleManager/bundleInfo'; +import * as _ExtensionAbilityInfo from './bundleManager/extensionAbilityInfo'; + +/** + * This module is used to obtain package information of various applications installed on the current device. + * @namespace bundleManager + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + declare namespace bundleManager { + /** + * Used to query the enumeration value of bundleInfo. Multiple values can be passed in the form. + * @enum { number } + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + enum BundleFlag { + /** + * Used to obtain the default bundleInfo. The obtained bundleInfo does not contain information of + * signatureInfo, applicationInfo, hapModuleInfo, ability, extensionAbility and permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_DEFAULT = 0x00000000, + /** + * Used to obtain the bundleInfo containing applicationInfo. The obtained bundleInfo does not + * contain the information of signatureInfo, hapModuleInfo, ability, extensionAbility and permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_APPLICATION = 0x00000001, + /** + * Used to obtain the bundleInfo containing hapModuleInfo. The obtained bundleInfo does not + * contain the information of signatureInfo, applicationInfo, ability, extensionAbility and permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_HAP_MODULE = 0x00000002, + /** + * Used to obtain the bundleInfo containing ability. The obtained bundleInfo does not + * contain the information of signatureInfo, applicationInfo, extensionAbility and permission. + * It can't be used alone, it needs to be used with GET_BUNDLE_INFO_WITH_HAP_MODULE. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_ABILITY = 0x00000004, + /** + * Used to obtain the bundleInfo containing extensionAbility. The obtained bundleInfo does not + * contain the information of signatureInfo, applicationInfo, ability and permission. + * It can't be used alone, it needs to be used with GET_BUNDLE_INFO_WITH_HAP_MODULE. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY = 0x00000008, + /** + * Used to obtain the bundleInfo containing permission. The obtained bundleInfo does not + * contain the information of signatureInfo, applicationInfo, hapModuleInfo, extensionAbility and ability. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION = 0x00000010, + /** + * Used to obtain the metadata contained in applicationInfo, moduleInfo and abilityInfo. + * It can't be used alone, it needs to be used with GET_BUNDLE_INFO_WITH_APPLICATION, + * GET_BUNDLE_INFO_WITH_HAP_MODULE, GET_BUNDLE_INFO_WITH_ABILITIES, GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_METADATA = 0x00000020, + /** + * Used to obtain the default bundleInfo containing disabled application and ability. + * The obtained bundleInfo does not contain information of signatureInfo, applicationInfo, + * hapModuleInfo, ability, extensionAbility and permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040, + /** + * Used to obtain the bundleInfo containing signatureInfo. The obtained bundleInfo does not + * contain the information of applicationInfo, hapModuleInfo, extensionAbility, ability and permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080, + } + + /** + * Used to query the enumeration value of applicationInfo. Multiple values can be passed in the form. + * @enum { number } + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + enum ApplicationFlag { + /** + * Used to obtain the default applicationInfo. The obtained applicationInfo does not contain the information of + * permission and metadata. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_APPLICATION_INFO_DEFAULT = 0x00000000, + /** + * Used to obtain the applicationInfo containing permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000001, + /** + * Used to obtain the applicationInfo containing metadata. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_APPLICATION_INFO_WITH_METADATA = 0x00000002, + /** + * Used to obtain the applicationInfo containing disabled application. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_APPLICATION_INFO_WITH_DISABLE = 0x00000004, + } + +/** + * Used to query the enumeration value of abilityInfo. Multiple values can be passed in the form. + * @enum { number } + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + enum AbilityFlag { + /** + * Used to obtain the default abilityInfo. The obtained abilityInfo does not contain the information of + * permission, metadata and disabled abilityInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_ABILITY_INFO_DEFAULT = 0x00000000, + /** + * Used to obtain the abilityInfo containing disabled abilityInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_ABILITY_INFO_WITH_PERMISSION = 0x00000001, + /** + * Used to obtain the abilityInfo containing applicationInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_ABILITY_INFO_WITH_APPLICATION = 0x00000002, + /** + * Used to obtain the abilityInfo containing metadata. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_ABILITY_INFO_WITH_METADATA = 0x00000004, + /** + * Used to obtain the abilityInfo containing disabled abilityInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_ABILITY_INFO_WITH_DISABLE = 0x00000008, + /** + * Used to obtain the abilityInfo only for system app. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_ABILITY_INFO_ONLY_SYSTEM_APP = 0x00000010, + } + + /** + * Used to query the enumeration value of ExtensionAbilityInfo. Multiple values can be passed in the form. + * @enum { number } + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + enum ExtensionAbilityFlag { + /** + * Used to obtain the default extensionAbilityInfo. The obtained extensionAbilityInfo does not contain the information of + * permission, metadata and disabled abilityInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_EXTENSION_ABILITY_INFO_DEFAULT = 0x00000000, + /** + * Used to obtain the extensionAbilityInfo containing permission. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_EXTENSION_ABILITY_INFO_WITH_PERMISSION = 0x00000001, + /** + * Used to obtain the extensionAbilityInfo containing applicationInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION = 0x00000002, + /** + * Used to obtain the extensionAbilityInfo containing metadata. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + GET_EXTENSION_ABILITY_INFO_WITH_METADATA = 0x00000004, + } + + /** + * This enumeration value is used to identify various types of extension ability + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export enum ExtensionAbilityType { + /** + * Indicates extension info with type of form + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + FORM = 0, + + /** + * Indicates extension info with type of work schedule + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + WORK_SCHEDULER = 1, + + /** + * Indicates extension info with type of input method + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + INPUT_METHOD = 2, + + /** + * Indicates extension info with type of service + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + SERVICE = 3, + + /** + * Indicates extension info with type of accessibility + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + ACCESSIBILITY = 4, + + /** + * Indicates extension info with type of dataShare + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + DATA_SHARE = 5, + + /** + * Indicates extension info with type of filesShare + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + FILE_SHARE = 6, + + /** + * Indicates extension info with type of staticSubscriber + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + STATIC_SUBSCRIBER = 7, + + /** + * Indicates extension info with type of wallpaper + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + WALLPAPER = 8, + + /** + * Indicates extension info with type of backup + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + BACKUP = 9, + + /** + * Indicates extension info with type of window + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + WINDOW = 10, + + /** + * Indicates extension info with type of enterprise admin + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + ENTERPRISE_ADMIN = 11, + + /** + * Indicates extension info with type of thumbnail + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + THUMBNAIL = 13, + + /** + * Indicates extension info with type of preview + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + PREVIEW = 14, + + /** + * Indicates extension info with type of unspecified + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + UNSPECIFIED = 255, + } + + /** + * PermissionGrantState + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export enum PermissionGrantState { + /** + * PERMISSION_DENIED + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + PERMISSION_DENIED = -1, + + /** + * PERMISSION_GRANTED + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + PERMISSION_GRANTED = 0, + } + + /** + * Support window mode + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export enum SupportWindowMode { + /** + * Indicates supported window mode of full screen mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + FULL_SCREEN = 0, + /** + * Indicates supported window mode of split mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + SPLIT = 1, + /** + * Indicates supported window mode of floating mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + FLOATING = 2, + } + + /** + * Launch type + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export enum LaunchType { + /** + * Indicates that the ability has only one instance + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + SINGLETON = 0, + + /** + * Indicates that the ability can have multiple instances + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + STANDARD = 1, + + /** + * Indicates that the ability can have specified instances + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + SPECIFIED = 2, + } + + /** + * Indicates ability type + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @FAModelOnly + * @since 9 + */ + export enum AbilityType { + /** + * Indicates that the ability has a UI + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + PAGE = 1, + + /** + * Indicates that the ability does not have a UI + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + SERVICE = 2, + + /** + * Indicates that the ability is used to provide data access services + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + DATA = 3, + } + + /** + * Display orientation + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export enum DisplayOrientation { + /** + * Indicates that the system automatically determines the display orientation + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + UNSPECIFIED, + + /** + * Indicates the landscape orientation + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + LANDSCAPE, + + /** + * Indicates the portrait orientation + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + PORTRAIT, + + /** + * Indicates the page ability orientation is the same as that of the nearest ability in the stack + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + FOLLOW_RECENT, + + /** + * Indicates the inverted landscape orientation + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + LANDSCAPE_INVERTED, + + /** + * Indicates the inverted portrait orientation + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + PORTRAIT_INVERTED, + + /** + * Indicates the orientation can be auto-rotated + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + AUTO_ROTATION, + + /** + * Indicates the landscape orientation rotated with sensor + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + AUTO_ROTATION_LANDSCAPE, + + /** + * Indicates the portrait orientation rotated with sensor + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + AUTO_ROTATION_PORTRAIT, + + /** + * Indicates the sensor restricted mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + AUTO_ROTATION_RESTRICTED, + + /** + * Indicates the sensor landscape restricted mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + AUTO_ROTATION_LANDSCAPE_RESTRICTED, + + /** + * Indicates the sensor portrait restricted mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + AUTO_ROTATION_PORTRAIT_RESTRICTED, + + /** + * Indicates the locked orientation mode + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + LOCKED, + } + + /** + * Obtains own bundleInfo. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo objects that will be returned. + * @returns { Promise } The result of getting the bundle info. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + function getBundleInfoForSelf(bundleFlags: number): Promise; + + /** + * Obtains own bundleInfo. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo objects that will be returned. + * @param { AsyncCallback } callback - The callback of getting bundle info result. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + function getBundleInfoForSelf(bundleFlags: number, callback: AsyncCallback): void; + + /** + * Obtains bundleInfo based on bundleName, bundleFlags and options. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo objects that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @param { AsyncCallback } callback - The callback of getting bundle info result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback): void; + function getBundleInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback): void; + + /** + * Obtains bundleInfo based on bundleName, bundleFlags and options. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo objects that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns { Promise } The result of getting the bundle info. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInfo(bundleName: string, bundleFlags: number, userId?: number): Promise; + + /** + * Obtains application info based on a given bundle name. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } appFlags - Indicates the flag used to specify information contained in the ApplicationInfo objects that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @param { AsyncCallback } callback - The callback of getting application info result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getApplicationInfo(bundleName: string, appFlags: number, callback: AsyncCallback): void; + function getApplicationInfo(bundleName: string, appFlags: number, userId: number, callback: AsyncCallback): void; + + /** + * Obtains application info based on a given bundle name. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } appFlags - Indicates the flag used to specify information contained in the ApplicationInfo objects that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns { Promise } The result of getting the application info. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getApplicationInfo(bundleName: string, appFlags: number, userId?: number): Promise; + + /** + * Obtains BundleInfo of all bundles available in the system. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo that will be returned. + * @param { number } userId - Indicates the user id. + * @param { AsyncCallback } callback - The callback of getting a list of BundleInfo objects. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getAllBundleInfo(bundleFlags: number, callback: AsyncCallback>): void; + function getAllBundleInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void; + + /** + * Obtains BundleInfo of all bundles available in the system. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo that will be returned. + * @param { number } userId - Indicates the user id. + * @returns { Promise> } Returns a list of BundleInfo objects. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getAllBundleInfo(bundleFlags: number, userId?: number): Promise>; + + /** + * Obtains information about all installed applications of a specified user. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { number } appFlags - Indicates the flag used to specify information contained in the ApplicationInfo objects that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @param { AsyncCallback } callback - The callback of getting a list of ApplicationInfo objects. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getAllApplicationInfo(appFlags: number, callback: AsyncCallback>): void; + function getAllApplicationInfo(appFlags: number, userId: number, callback: AsyncCallback>): void; + + /** + * Obtains information about all installed applications of a specified user. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { number } appFlags - Indicates the flag used to specify information contained in the ApplicationInfo objects that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns { Promise> } Returns a list of ApplicationInfo objects. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getAllApplicationInfo(appFlags: number, userId?: number): Promise>; + + /** + * Query the AbilityInfo by the given Want. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { Want } want - Indicates the Want containing the application bundle name to be queried. + * @param { number } abilityFlags - Indicates the flag used to specify information contained in the AbilityInfo objects that will be returned. + * @param { number } userId - userId Indicates the user ID. + * @param { AsyncCallback> } callback - The callback of querying ability info result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified ability is not found. + * @throws { BusinessError } 17700004 - The specified userId is invalid. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function queryAbilityInfo(want: Want, abilityFlags: number, callback: AsyncCallback>): void; + function queryAbilityInfo(want: Want, abilityFlags: number, userId: number, callback: AsyncCallback>): void; + + /** + * Query the AbilityInfo by the given Want. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { Want } want - Indicates the Want containing the application bundle name to be queried. + * @param { number } abilityFlags - Indicates the flag used to specify information contained in the AbilityInfo objects that will be returned. + * @param { number } userId - userId Indicates the user ID. + * @returns { Promise> } Returns a list of AbilityInfo objects. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified extensionAbility is not found. + * @throws { BusinessError } 17700004 - The specified userId is invalid. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function queryAbilityInfo(want: Want, abilityFlags: number, userId?: number): Promise>; + + /** + * Query extension info of by utilizing a Want. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { Want } want - Indicates the Want containing the application bundle name to be queried. + * @param { ExtensionAbilityType } extensionAbilityType - Indicates ExtensionAbilityType. + * @param { number } extensionAbilityFlags - Indicates the flag used to specify information contained in the ExtensionAbilityInfo objects that will be returned. + * @param { number } userId - Indicates the user ID. + * @param { AsyncCallback> } callback - The callback of querying extension ability info result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified extensionAbility is not found. + * @throws { BusinessError } 17700004 - The specified userId is invalid. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, callback: AsyncCallback>): void; + function queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId: number, callback: AsyncCallback>): void; + + /** + * Query the ExtensionAbilityInfo by the given Want. ohos.permission.GET_BUNDLE_INFO_PRIVILEGED is required for cross user access. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { Want } want - Indicates the Want containing the application bundle name to be queried. + * @param { ExtensionAbilityType } extensionAbilityType - Indicates ExtensionAbilityType. + * @param { number } extensionAbilityFlags - Indicates the flag used to specify information contained in the ExtensionAbilityInfo objects that will be returned. + * @param { number } userId - Indicates the user ID. + * @returns { Promise> } Returns a list of ExtensionAbilityInfo objects. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified extensionAbility is not found. + * @throws { BusinessError } 17700004 - The specified userId is invalid. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function queryExtensionAbilityInfo(want: Want, extensionAbilityType: ExtensionAbilityType, extensionAbilityFlags: number, userId?: number): Promise>; + + /** + * Obtains bundle name by the given uid. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { number } uid - Indicates the UID of an application. + * @param { AsyncCallback } callback - The callback of getting bundle name. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700021 - The uid is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleNameByUid(uid: number, callback: AsyncCallback): void + + /** + * Obtains bundle name by the given uid. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { number } uid - Indicates the UID of an application. + * @returns { Promise } Returns the bundle name. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700021 - The uid is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleNameByUid(uid: number): Promise; + + /** + * Obtains information about an application bundle contained in an ohos Ability Package (HAP). + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } hapFilePath - Indicates the path storing the HAP. The path should be the relative path to the data directory of the current application. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo object to be returned. + * @param { AsyncCallback } callback - The callback of getting bundle archive info result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700022 - The hapFilePath is invalid. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback): void + + /** + * Obtains information about an application bundle contained in an ohos Ability Package (HAP). + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } hapFilePath - Indicates the path storing the HAP. The path should be the relative path to the data directory of the current application. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo object to be returned. + * @returns { Promise } Returns the BundleInfo object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700022 - The hapFilePath is invalid. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise; + + /** + * Clears cache data of a specified application. + * @permission ohos.permission.REMOVE_CACHE_FILES + * @param { string } bundleName - Indicates the bundle name of the application whose cache data is to be cleaned. + * @param { AsyncCallback } callback - The callback of cleaning bundle cache files result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700030 - The specified bundleName does not support cleaning cache files. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback): void; + + /** + * Clears cache data of a specified application. + * @permission ohos.permission.REMOVE_CACHE_FILES + * @param { string } bundleName - Indicates the bundle name of the application whose cache data is to be cleaned. + * @returns { Promise } Clean bundle cache files result + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700030 - The specified bundleName does not support cleaning cache files. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function cleanBundleCacheFiles(bundleName: string): Promise; + + /** + * Sets whether to enable a specified application. + * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { boolean } isEnabled - The value true means to enable it, and the value false means to disable it. + * @param { AsyncCallback } callback - The callback of setting app enabled result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function setApplicationEnabled(bundleName: string, isEnabled: boolean, callback: AsyncCallback): void; + + /** + * Sets whether to enable a specified application. + * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { boolean } isEnabled - The value true means to enable it, and the value false means to disable it. + * @returns { Promise } set app enabled result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function setApplicationEnabled(bundleName: string, isEnabled: boolean): Promise; + + /** + * Sets whether to enable a specified ability. + * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE + * @param { AbilityInfo } abilityInfo - Indicates information about the ability to set. + * @param { boolean } isEnabled - The value true means to enable it, and the value false means to disable it. + * @param { AsyncCallback } callback - The callback of setting ability enabled result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityInfo is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function setAbilityEnabled(info: AbilityInfo, isEnabled: boolean, callback: AsyncCallback): void; + + /** + * Sets whether to enable a specified ability. + * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE + * @param { AbilityInfo } abilityInfo - Indicates information about the ability to set. + * @param { boolean } isEnabled - The value true means to enable it, and the value false means to disable it. + * @returns { Promise } set ability enabled result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityInfo is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function setAbilityEnabled(info: AbilityInfo, isEnabled: boolean): Promise; + + /** + * Checks whether a specified application is enabled. + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { AsyncCallback } callback - The callback of checking application enabled result. The result is true if enabled, false otherwise. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function isApplicationEnabled(bundleName: string, callback: AsyncCallback): void; + + /** + * Checks whether a specified application is enabled. + * @param { string } bundleName - Indicates the bundle name of the application. + * @returns { Promise } Returns true if the application is enabled; returns false otherwise. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function isApplicationEnabled(bundleName: string): Promise; + + /** + * Checks whether a specified ability is enabled. + * @param { AbilityInfo } info - Indicates information about the ability to check. + * @param { AsyncCallback } callback - The callback of checking ability enabled result. The result is true if enabled, false otherwise. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityName is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback): void; + + /** + * Checks whether a specified ability is enabled. + * @param { AbilityInfo } info - Indicates information about the ability to check. + * @returns { Promise } Returns true if the ability is enabled; returns false otherwise. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityName is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function isAbilityEnabled(info: AbilityInfo): 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 or module.json file. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @param { AsyncCallback } callback - The callback for starting the application's main ability. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback): void; + + /** + * 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 or module.json file. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { AsyncCallback } callback - The callback for starting the application's main ability. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; + + /** + * 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 or module.json file. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns { Promise } the Want for starting the application's main ability. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getLaunchWantForBundle(bundleName: string, userId?: number): Promise; + + /** + * Obtains the profile designated by metadata name, abilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } abilityName - Indicates the abilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @param { AsyncCallback> } callback - The callback of returning string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700002 - The specified moduleName is not existed. + * @throws { BusinessError } 17700003 - The specified abilityName is not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + function getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void; + + /** + * Obtains the profile designated by metadata name, abilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } abilityName - Indicates the abilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @returns { Promise> } Returns string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700002 - The specified moduleName is not existed. + * @throws { BusinessError } 17700003 - The specified abilityName is not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + function getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>; + + /** + * Obtains the profile designated by metadata name, extensionAbilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } extensionAbilityName - Indicates the extensionAbilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @param { AsyncCallback } callback - The callback of returning string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700002 - The specified moduleName is not existed. + * @throws { BusinessError } 17700003 - The specified extensionAbilityName not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void; + + /** + * Obtains the profile designated by metadata name, extensionAbilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } extensionAbilityName - Indicates the extensionAbilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @returns { Promise> } Returns string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700002 - The specified moduleName is not existed. + * @throws { BusinessError } 17700003 - The specified extensionAbilityName not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>; + + /** + * Get the permission details by permission name. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } permissionName - Indicates permission name. + * @param { AsyncCallback } callback - The callback of get permissionDef object result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700006 - The specified permission is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getPermissionDef(permissionName: string, callback: AsyncCallback): void; + + /** + * Get the permission details by permission name. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } permissionName - Indicates permission name. + * @returns { Promise } Returns permissionDef object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700006 - The specified permission is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getPermissionDef(permissionName: string): Promise; + + /** + * Obtains the label of a specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the bundle name of the application to which the ability belongs. + * @param { string } moduleName - Indicates the module name. + * @param { string } abilityName - Indicates the ability name. + * @param { AsyncCallback } callback - The callback of getting ability label result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700002 - The specified moduleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityName is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Resource + * @systemapi + * @since 9 + */ + function getAbilityLabel(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback): void; + + /** + * Obtains the label of a specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the bundle name of the application to which the ability belongs. + * @param { string } moduleName - Indicates the module name. + * @param { string } abilityName - Indicates the ability name. + * @returns { Promise } Returns the label representing the label of the specified ability. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700002 - The specified moduleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityName is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Resource + * @systemapi + * @since 9 + */ + function getAbilityLabel(bundleName: string, moduleName: string, abilityName: string): Promise; + + /** + * Obtains the icon of a specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the bundle name of the application to which the ability belongs. + * @param { string } moduleName - Indicates the module name. + * @param { string } abilityName - Indicates the ability name. + * @param { AsyncCallAsyncCallback } callback - The callback of getting ability icon result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700002 - The specified moduleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityName is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Resource + * @systemapi + * @since 9 + */ + function getAbilityIcon(bundleName: string, moduleName: string, abilityName: string, callback: AsyncCallback): void; + + /** + * Obtains the icon of a specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the bundle name of the application to which the ability belongs. + * @param { string } moduleName - Indicates the module name. + * @param { string } abilityName - Indicates the ability name. + * @returns { Promise } Returns the PixelMap object representing the icon of the specified ability. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700002 - The specified moduleName is not found. + * @throws { BusinessError } 17700003 - The specified abilityName is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @throws { BusinessError } 17700029 - The specified ability is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Resource + * @systemapi + * @since 9 + */ + function getAbilityIcon(bundleName: string, moduleName: string, abilityName: string): Promise; + + /** + * Obtains applicationInfo based on a given bundleName and bundleFlags. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } applicationFlags - Indicates the flag used to specify information contained in the ApplicationInfo object that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns Returns the ApplicationInfo object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : ApplicationInfo; + function getApplicationInfoSync(bundleName: string, applicationFlags: number) : ApplicationInfo; + + /** + * Obtains bundleInfo based on bundleName, bundleFlags and options. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } bundleFlags - Indicates the flag used to specify information contained in the BundleInfo object that will be returned. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns Returns the BundleInfo object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not found. + * @throws { BusinessError } 17700004 - The specified userId is not found. + * @throws { BusinessError } 17700026 - The specified bundle is disabled. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInfoSync(bundleName: string, bundleFlags: number, userId: number): BundleInfo; + function getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo; + + /** + * Obtains configuration information about an application. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type ApplicationInfo = _ApplicationInfo; + + /** + * Indicates the Metadata. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type Metadata = _Metadata; + + /** + * Obtains configuration information about a bundle. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type BundleInfo = _BundleInfo.BundleInfo; + + /** + * The scene which is used. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type UsedScene = _BundleInfo.UsedScene; + + /** + * Indicates the required permissions details defined in file config.json. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type ReqPermissionDetail = _BundleInfo.ReqPermissionDetail; + + /** + * Indicates the SignatureInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type SignatureInfo = _BundleInfo.SignatureInfo; + + /** + * Obtains configuration information about an module. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type HapModuleInfo = _HapModuleInfo; + + /** + * Obtains configuration information about an ability. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type AbilityInfo = _AbilityInfo.AbilityInfo; + + /** + * Contains basic Ability information. Indicates the window size.. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type WindowSize = _AbilityInfo.WindowSize; + + /** + * Obtains extension information about a bundle. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type ExtensionAbilityInfo = _ExtensionAbilityInfo.ExtensionAbilityInfo; + + /** + * Indicates the defined permission details in file config.json. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + export type PermissionDef = _PermissionDef; + + /** + * Contains basic Ability information, which uniquely identifies an ability. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export type ElementName = _ElementName; +} + +export default bundleManager; diff --git a/api/@ohos.bundle.bundleMonitor.d.ts b/api/@ohos.bundle.bundleMonitor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b56af8dda540fb6a8acd38d86dc371d07a0529d8 --- /dev/null +++ b/api/@ohos.bundle.bundleMonitor.d.ts @@ -0,0 +1,85 @@ +/* + * 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'; + +/** + * Bundle monitor + * @namespace bundleMonitor + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ +declare namespace bundleMonitor { + /** + * This module defines the result information of monitoring install, update and uninstall. + * @typedef BundleChangedInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + interface BundleChangedInfo { + /** + * The bundle name + * @type {string} + * @systemapi + * @since 9 + */ + readonly bundleName: string; + /** + * The user id + * @type {number} + * @systemapi + * @since 9 + */ + readonly userId: number; + } + + /** + * Indicates the event type of bundle change + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + type BundleChangedEvent = 'add' | 'update' | 'remove'; + + /** + * Register to monitor the installation status + * @permission ohos.permission.LISTEN_BUNDLE_CHANGE + * @param { BundleChangedEvent } type - Indicates the command should be implement. + * @param { Callback } callback - Indicates the callback to be register. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function on(type: BundleChangedEvent, callback: Callback): void; + + /** + * Unregister to monitor the installation status + * @permission ohos.permission.LISTEN_BUNDLE_CHANGE + * @param { BundleChangedEvent } type -type Indicates the command should be implement. + * @param { Callback } callback - Indicates the callback to be unregister. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function off(type: BundleChangedEvent, callback?: Callback): void; +} + +export default bundleMonitor diff --git a/api/@ohos.bundle.d.ts b/api/@ohos.bundle.d.ts index 468be9fb97238214a070f680c72daccf4123437f..7279d03950247a5174c2cbb2eb9700bca02dcb70 100644 --- a/api/@ohos.bundle.d.ts +++ b/api/@ohos.bundle.d.ts @@ -13,23 +13,14 @@ * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; -import { ApplicationInfo as _ApplicationInfo } from './bundle/applicationInfo'; -import { ModuleInfo as _ModuleInfo } from './bundle/moduleInfo'; -import { CustomizeData as _CustomizeData } from './bundle/customizeData'; -import { Metadata as _Metadata } from './bundle/metadata'; -import { HapModuleInfo as _HapModuleInfo } from './bundle/hapModuleInfo'; -import { AbilityInfo as _AbilityInfo } from './bundle/abilityInfo'; -import { ExtensionAbilityInfo as _ExtensionAbilityInfo } from './bundle/extensionAbilityInfo'; -import { PermissionDef as _PermissionDef } from './bundle/PermissionDef'; -import { ElementName as _ElementName } from './bundle/elementName'; -import { DispatchInfo as _DispatchInfo } from './bundle/dispatchInfo'; +import { AsyncCallback } from './basic'; +import { ApplicationInfo } from './bundle/applicationInfo'; +import { AbilityInfo } from './bundle/abilityInfo'; +import { PermissionDef } from './bundle/PermissionDef'; import Want from './@ohos.application.Want'; import image from './@ohos.multimedia.image'; -import pack from './bundle/packInfo'; -import * as _PackInfo from './bundle/packInfo'; -import * as _BundleInfo from './bundle/bundleInfo'; -import * as _BundleInstaller from './bundle/bundleInstaller'; +import { BundleInfo } from './bundle/bundleInfo'; +import { BundleInstaller } from './bundle/bundleInstaller'; /** * bundle. @@ -37,6 +28,8 @@ import * as _BundleInstaller from './bundle/bundleInstaller'; * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager */ declare namespace bundle { @@ -46,6 +39,9 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.BundleFlag, ohos.bundle.bundleManager.ApplicationFlag or + * ohos.bundle.bundleManager.AbilityFlag */ enum BundleFlag { GET_BUNDLE_DEFAULT = 0x00000000, @@ -59,14 +55,6 @@ declare namespace bundle { * @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 */ @@ -83,24 +71,6 @@ declare namespace bundle { * @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, } /** @@ -109,6 +79,7 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 */ export enum ColorMode { AUTO_MODE = -1, @@ -122,6 +93,8 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.PermissionGrantState */ export enum GrantStatus { PERMISSION_DENIED = -1, @@ -134,6 +107,8 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.AbilityType */ export enum AbilityType { /** @@ -171,6 +146,7 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 */ export enum AbilitySubType { UNSPECIFIED = 0, @@ -183,6 +159,8 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.DisplayOrientation */ export enum DisplayOrientation { /** @@ -212,69 +190,6 @@ declare namespace bundle { * @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, } /** @@ -283,6 +198,8 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.LaunchType */ export enum LaunchMode { /** @@ -300,112 +217,13 @@ declare namespace bundle { 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 thumbnail - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - THUMBNAIL = 13, - /** - * @default Indicates extension info with type of preview - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - PREVIEW = 14, - /** - * @default Indicates extension info with type of unspecified - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - UNSPECIFIED = 255, - } - /** * @name BundleOptions * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 */ export interface BundleOptions { /** @@ -422,6 +240,7 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @import NA * @permission NA + * @deprecated since 9 */ export enum InstallErrorCode{ SUCCESS = 0, @@ -467,61 +286,6 @@ declare namespace bundle { STATUS_UNINSTALL_PERMISSION_DENIED = 0x45, } - /** - * @name UpgradeFlag - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi Hide this for inner system use - */ - export enum UpgradeFlag { - /** - * @default Indicates module not need to be upgraded - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - NOT_UPGRADE = 0, - /** - * @default Indicates single module need to be upgraded - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - SINGLE_UPGRADE = 1, - /** - * @default Indicates relation module need to be upgraded - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - RELATION_UPGRADE = 2, - } - - /** - * @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. * @@ -532,6 +296,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getBundleInfo */ function getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback): void; function getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback): void; @@ -545,6 +311,8 @@ declare namespace bundle { * @return Returns the IBundleInstaller interface. * @permission ohos.permission.INSTALL_BUNDLE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer#getBundleInstaller */ function getBundleInstaller(callback: AsyncCallback): void; function getBundleInstaller(): Promise; @@ -558,6 +326,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#queryAbilityInfo */ function getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback): void; function getAbilityInfo(bundleName: string, abilityName: string): Promise; @@ -573,6 +343,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getApplicationInfo */ function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback) : void; function getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback) : void; @@ -590,6 +362,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#queryAbilityInfo */ function queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void; function queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void; @@ -605,6 +379,8 @@ declare namespace bundle { * @param userId Indicates the user id. * @return Returns a list of BundleInfo objects. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getAllBundleInfo */ function getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>) : void; function getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>) : void; @@ -620,6 +396,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getAllApplicationInfo */ function getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>) : void; function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; @@ -632,6 +410,8 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @param uid Indicates the UID of an application. * @return Returns the bundle name. + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getNameForUid */ function getNameForUid(uid: number, callback: AsyncCallback) : void function getNameForUid(uid: number) : Promise; @@ -646,6 +426,8 @@ declare namespace bundle { * @param bundleFlags Indicates the flag used to specify information contained in the BundleInfo object to be * returned. * @return Returns the BundleInfo object. + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getBundleArchiveInfo */ function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback) : void function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise; @@ -662,6 +444,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getLaunchWantForBundle */ function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; function getLaunchWantForBundle(bundleName: string): Promise; @@ -675,6 +459,8 @@ declare namespace bundle { * @param callback Indicates the callback to be invoked for returning the operation result. * @permission ohos.permission.REMOVE_CACHE_FILES * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#cleanBundleCacheFiles */ function cleanBundleCacheFiles(bundleName: string, callback: AsyncCallback): void; function cleanBundleCacheFiles(bundleName: string): Promise; @@ -689,6 +475,8 @@ declare namespace bundle { * value false means to disable it. * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#setApplicationEnabled */ function setApplicationEnabled(bundleName: string, isEnable: boolean, callback: AsyncCallback): void; function setApplicationEnabled(bundleName: string, isEnable: boolean): Promise; @@ -703,26 +491,12 @@ declare namespace bundle { * value false means to disable it.. * @permission ohos.permission.CHANGE_ABILITY_ENABLED_STATE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#setAbilityEnabled */ function setAbilityEnabled(info: AbilityInfo, isEnable: boolean, callback: AsyncCallback): void; function setAbilityEnabled(info: AbilityInfo, isEnable: boolean): 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>; - /** * Get the permission details by permissionName. * @@ -732,6 +506,8 @@ declare namespace bundle { * @return Returns permissionDef object. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @systemapi + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getPermissionDef */ function getPermissionDef(permissionName: string, callback: AsyncCallback): void; function getPermissionDef(permissionName: string): Promise; @@ -745,6 +521,8 @@ declare namespace bundle { * @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. + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getAbilityLabel */ function getAbilityLabel(bundleName: string, abilityName: string, callback: AsyncCallback): void; function getAbilityLabel(bundleName: string, abilityName: string): Promise; @@ -758,6 +536,8 @@ declare namespace bundle { * @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 + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getAbilityIcon */ function getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback): void; function getAbilityIcon(bundleName: string, abilityName: string): Promise; @@ -769,7 +549,9 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @param info Indicates information about the ability to check. * @returns Returns true if the ability is enabled; returns false otherwise. - */ + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#isAbilityEnabled + */ function isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback): void; function isAbilityEnabled(info: AbilityInfo): Promise; @@ -780,434 +562,11 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @param bundleName Indicates the bundle name of the application. * @returns Returns true if the application is enabled; returns false otherwise. + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#isApplicationEnabled */ function isApplicationEnabled(bundleName: string, callback: AsyncCallback): void; function isApplicationEnabled(bundleName: string): Promise; - - /** - * Set the module wether need upgrade - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param bundleName Indicates the bundle name of the application. - * @param moduleName Indicates the module name of the application. - * @param upgradeFlag Indicates upgradeFlag of the application. - * @systemapi Hide this for inner system use - */ - function setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback):void; - function setModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise; - - /** - * Checks whether a specified module is removable. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param bundleName Indicates the bundle name of the application. - * @param moduleName Indicates the module name of the application. - * @returns Returns true if the module is removable; returns false otherwise. - * @systemapi Hide this for inner system use - */ - function isModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback): void; - function isModuleRemovable(bundleName: string, moduleName: string): Promise; - - /** - * Obtains bundlePackInfo based on bundleName and bundleFlags. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param bundleName Indicates the application bundle name to be queried. - * @param bundlePackFlag Indicates the application bundle pack flag to be queried. - * @return Returns the BundlePackInfo object. - * @systemapi hide this for inner system use - */ - function getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag, callback: AsyncCallback): void; - function getBundlePackInfo(bundleName: string, bundlePackFlag : pack.BundlePackFlag): 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 information about the dispatcher version. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @return Returns the DispatchInfo object for the current ability. - * @systemapi hide this for inner system use - */ - function getDispatcherVersion(callback: AsyncCallback): void; - function getDispatcherVersion(): 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>; - - /** - * Set the disposed status of a specified bundle. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param bundleName Indicates the bundle name of the application. - * @param status Indicates the disposed status. - * @return Returns the disposed status of a specified bundle. - * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS - * @systemapi Hide this for inner system use - */ - function setDisposedStatus(bundleName: string, status: number, callback: AsyncCallback): void; - function setDisposedStatus(bundleName: string, status: number): Promise; - - /** - * Obtains the disposed status of a specified bundle. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param bundleName Indicates the bundle name of the application. - * @return Returns the disposed status of a specified bundle. - * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS - * @systemapi Hide this for inner system use - */ - function getDisposedStatus(bundleName: string, callback: AsyncCallback): void; - function getDisposedStatus(bundleName: string): Promise; - - /** - * Obtains based on a given bundleName and bundleFlags. - * - * @since 9 - * @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 getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number) : ApplicationInfo; - function getApplicationInfoSync(bundleName: string, bundleFlags: number) : ApplicationInfo; - - /** - * Obtains bundleInfo based on bundleName, bundleFlags and options. - * - * @since 9 - * @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 BundleInfo object - * that will be returned. - * @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 getBundleInfoSync(bundleName: string, bundleFlags: number, options: BundleOptions): BundleInfo; - function getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo; - - /** - * Obtains configuration information about an application. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type ApplicationInfo = _ApplicationInfo; - - /** - * Stores module information about an application. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type ModuleInfo = _ModuleInfo; - - /** - * Indicates the custom metadata. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type CustomizeData = _CustomizeData; - - /** - * Indicates the Metadata. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type Metadata = _Metadata; - - /** - * Obtains configuration information about a bundle. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type BundleInfo = _BundleInfo.BundleInfo; - - /** - * The scene which is used. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type UsedScene = _BundleInfo.UsedScene; - - /** - * Indicates the required permissions details defined in file config.json. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type ReqPermissionDetail = _BundleInfo.ReqPermissionDetail; - - /** - * Obtains configuration information about an module. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type HapModuleInfo = _HapModuleInfo; - - /** - * Obtains configuration information about an ability. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type AbilityInfo = _AbilityInfo; - - /** - * Obtains extension information about a bundle. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type ExtensionAbilityInfo = _ExtensionAbilityInfo; - - /** - * Offers install, upgrade, and remove bundles on the devices. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type BundleInstaller = _BundleInstaller.BundleInstaller; - - /** - * Provides parameters required for hashParam. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type HashParam = _BundleInstaller.HashParam; - - /** - * Provides parameters required for installing or uninstalling an application. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type InstallParam = _BundleInstaller.InstallParam; - - /** - * Indicates the install or uninstall status. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type InstallStatus = _BundleInstaller.InstallStatus; - - /** - * Indicates the defined permission details in file config.json. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type PermissionDef = _PermissionDef; - - /** - * Contains basic Ability information, which uniquely identifies an ability. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type ElementName = _ElementName; - - /** - * The dispatch info class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type DispatchInfo = _DispatchInfo; - - /** - * The bundle pack info class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type BundlePackInfo = _PackInfo.BundlePackInfo; - - /** - * The package info class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type PackageConfig = _PackInfo.PackageConfig; - - /** - * The package summary class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type PackageSummary = _PackInfo.PackageSummary; - - /** - * The bundle summary class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type BundleConfigInfo = _PackInfo.BundleConfigInfo; - - /** - * The extension ability forms class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type ExtensionAbilities = _PackInfo.ExtensionAbilities; - - /** - * The module summary of a bundle. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type ModuleConfigInfo = _PackInfo.ModuleConfigInfo; - - /** - * The bundle info summary class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type ModuleDistroInfo = _PackInfo.ModuleDistroInfo; - - /** - * The ability info of a module. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type ModuleAbilityInfo = _PackInfo.ModuleAbilityInfo; - - /** - * The form info of an ability. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type AbilityFormInfo = _PackInfo.AbilityFormInfo; - - /** - * The bundle version class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type Version = _PackInfo.Version; - - /** - * The bundle Api version class. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type ApiVersion = _PackInfo.ApiVersion; - - /** - * Flags which are used to indicate bundle pack. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type BundlePackFlag = _PackInfo.BundlePackFlag; } export default bundle; diff --git a/api/@ohos.bundle.defaultAppManager.d.ts b/api/@ohos.bundle.defaultAppManager.d.ts index d467bb1b4a8d8e4d78dabfdff5e52e53682214e3..65a065a00cc609888b77cd985f0bfeba8937d26e 100644 --- a/api/@ohos.bundle.defaultAppManager.d.ts +++ b/api/@ohos.bundle.defaultAppManager.d.ts @@ -14,130 +14,205 @@ */ import { AsyncCallback } from './basic'; -import { BundleInfo } from './bundle/bundleInfo'; -import { ElementName } from './bundle/elementName'; +import { BundleInfo } from './bundleManager/bundleInfo'; +import { ElementName } from './bundleManager/elementName'; /** - * default application manager. - * @name defaultAppManager + * Default application manager. + * @namespace defaultAppManager + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @permission NA */ declare namespace defaultAppManager { /** - * the constant for application type. - * @name ApplicationType + * The constant for application type. + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @permission N/A */ export enum ApplicationType { /** - * default browser identifier. - * + * Default browser identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - BROWSER = "BROWSER", + BROWSER = "Web Browser", /** - * default image identifier. - * + * Default image identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - IMAGE = "IMAGE", + IMAGE = "Image Gallery", /** - * default audio identifier. - * + * Default audio identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - AUDIO = "AUDIO", + AUDIO = "Audio Player", /** - * default video identifier. - * + * Default video identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - VIDEO = "VIDEO", + VIDEO = "Video Player", /** - * default pdf identifier. - * + * Default PDF identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - PDF = "PDF", + PDF = "PDF Viewer", /** - * default word identifier. - * + * Default word identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - WORD = "WORD", + WORD = "Word Viewer", /** - * default excel identifier. - * + * Default excel identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - EXCEL = "EXCEL", + EXCEL = "Excel Viewer", /** - * default ppt identifier. - * + * Default PPT identifier. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 */ - PPT = "PPT", + PPT = "PPT Viewer", } /** - * query whether the caller is default application based on type. - * + * Query whether the caller is default application based on type. + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { AsyncCallback } callback - The callback of querying default application result. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @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; /** - * get default application based on type. - * + * Query whether the caller is default application based on type. + * @param { string } type - Application type or a file type that conforms to media type format. + * @returns { Promise } Return true if caller is default application; return false otherwise. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param type application type or file type. - * @param userId indicates the id for the user. - * @return return the BundleInfo object. + */ + function isDefaultApplication(type: string) : Promise; + + /** + * Get default application based on type. * @permission ohos.permission.GET_DEFAULT_APPLICATION - * @systemapi hide this for inner system use. + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { number } userId - Indicates the id for the user. + * @param { AsyncCallback } callback - The callback of the BundleInfo object result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700004 - The specified user id is not found. + * @throws { BusinessError } 17700023 - The specified default app does not exist. + * @throws { BusinessError } 17700025 - The specified type is invalid. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager + * @systemapi + * @since 9 */ - function getDefaultApplication(type: string, userId?: number) : Promise; function getDefaultApplication(type: string, userId: number, callback: AsyncCallback) : void; function getDefaultApplication(type: string, callback: AsyncCallback) : void; /** - * set default application based on type. - * + * Get default application based on type. + * @permission ohos.permission.GET_DEFAULT_APPLICATION + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { number } userId - Indicates the id for the user. + * @returns { Promise } Return the BundleInfo object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700004 - The specified user id is not found. + * @throws { BusinessError } 17700023 - The specified default app does not exist. + * @throws { BusinessError } 17700025 - The specified type is invalid. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager + * @systemapi * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param type application type or file type. - * @param elementName uniquely identifies an ability or extensionAbility. - * @param userId indicates the id for the user. + */ + function getDefaultApplication(type: string, userId?: number) : Promise; + + /** + * Set default application based on type. * @permission ohos.permission.SET_DEFAULT_APPLICATION - * @systemapi hide this for inner system use. + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { ElementName } elementName - Uniquely identifies an ability or extensionAbility. + * @param { number } userId - Indicates the id for the user. + * @param { AsyncCallback } callback - The callback of setting default application result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700004 - The specified user id is not found. + * @throws { BusinessError } 17700025 - The specified type is invalid. + * @throws { BusinessError } 17700028 - The specified ability and type does not match. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager + * @systemapi + * @since 9 */ - function setDefaultApplication(type: string, elementName: ElementName, userId?: number) : Promise; function setDefaultApplication(type: string, elementName: ElementName, userId: number, callback: AsyncCallback) : void; function setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCallback) : void; /** - * reset default application based on type. - * + * Set default application based on type. + * @permission ohos.permission.SET_DEFAULT_APPLICATION + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { ElementName } elementName - Uniquely identifies an ability or extensionAbility. + * @param { number } userId - Indicates the id for the user. + * @returns { Promise } The result of setting default application. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700004 - The specified user id is not found. + * @throws { BusinessError } 17700025 - The specified type is invalid. + * @throws { BusinessError } 17700028 - The specified ability and type does not match. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager + * @systemapi * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @param type application type or file type. - * @param userId indicates the id for the user. + */ + function setDefaultApplication(type: string, elementName: ElementName, userId?: number) : Promise; + + /** + * Reset default application based on type. * @permission ohos.permission.SET_DEFAULT_APPLICATION - * @systemapi hide this for inner system use. + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { number } userId - Indicates the id for the user. + * @param { AsyncCallback } callback - The callback of resetting default application result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700004 - The specified user id is not found. + * @throws { BusinessError } 17700025 - The specified type is invalid. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager + * @systemapi + * @since 9 */ - function resetDefaultApplication(type: string, userId?: number) : Promise; function resetDefaultApplication(type: string, userId: number, callback: AsyncCallback) : void; function resetDefaultApplication(type: string, callback: AsyncCallback) : void; + + /** + * Reset default application based on type. + * @permission ohos.permission.SET_DEFAULT_APPLICATION + * @param { string } type - Application type or a file type that conforms to media type format. + * @param { number } userId - Indicates the id for the user. + * @returns { Promise } The result of resetting default application. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700004 - The specified user id is not found. + * @throws { BusinessError } 17700025 - The specified type is invalid. + * @syscap SystemCapability.BundleManager.BundleFramework.DefaultAppManager + * @systemapi + * @since 9 + */ + function resetDefaultApplication(type: string, userId?: number) : Promise; } -export default defaultAppManager; +export default defaultAppManager; \ No newline at end of file diff --git a/api/@ohos.bundle.distributedBundle.d.ts b/api/@ohos.bundle.distributedBundle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..76c67d47bddf9a4244baed25dcba5ffd4bf80e04 --- /dev/null +++ b/api/@ohos.bundle.distributedBundle.d.ts @@ -0,0 +1,185 @@ +/* + * 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 { ElementName } from './bundleManager/elementName'; +import { RemoteAbilityInfo as _RemoteAbilityInfo } from './bundleManager/remoteAbilityInfo'; + +/** + * DistributedBundle manager. + * @namespace distributedBundle + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ +declare namespace distributedBundle { + /** + * Obtains information about the ability info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { ElementName } elementName - Indicates the elementName. + * @param { AsyncCallback } callback - The callback of getting the ability info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback): void; + + /** + * Obtains information about the ability info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { ElementName } elementName - Indicates the elementName. + * @returns { Promise } Returns the ability info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementName: ElementName): Promise; + + /** + * Obtains information about the abilities info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { Array } elementNames - Indicates the elementNames, Maximum array length ten. + * @param { AsyncCallback> } callback - the callback of getting the abilities info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementNames: Array, callback: AsyncCallback>): void; + + /** + * Obtains information about the abilities info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { Array } elementNames - Indicates the elementNames, Maximum array length ten. + * @returns { Promise> } The result of getting the abilities info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementNames: Array): Promise>; + + /** + * Obtains information about the ability info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { ElementName } elementName - Indicates the elementName. + * @param { string } locale - Indicates the locale info + * @param { AsyncCallback } callback - The callback of getting the ability info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCallback): void; + + /** + * Obtains information about the ability info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { ElementName } elementName - Indicates the elementName. + * @param { string } locale - Indicates the locale info + * @returns { Promise> } The result of getting the ability info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise; + + /** + * Obtains information about the ability info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { Array } elementNames - Indicates the elementNames, Maximum array length ten. + * @param { string } locale - Indicates the locale info + * @param { AsyncCallback } callback - Returns the abilities info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementNames: Array, locale: string, callback: AsyncCallback>): void; + + /** + * Obtains information about the abilities info of the remote device. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { Array } elementNames - Indicates the elementNames, Maximum array length ten. + * @param { string } locale - Indicates the locale info + * @returns { Promise> } Returns the abilities info of the remote device. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700003 - The specified ability name is not found. + * @throws { BusinessError } 17700007 - The specified device id is not found. + * @throws { BusinessError } 17700027 - The distributed service is not running. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + function getRemoteAbilityInfo(elementNames: Array, locale: string): Promise>; + + /** + * Contains basic remote ability information. + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ + export type RemoteAbilityInfo = _RemoteAbilityInfo; +} + +export default distributedBundle; diff --git a/api/@ohos.bundle.freeInstall.d.ts b/api/@ohos.bundle.freeInstall.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d42117b9be1a247cf290987f2aba6decd19ab8a --- /dev/null +++ b/api/@ohos.bundle.freeInstall.d.ts @@ -0,0 +1,313 @@ +/* + * 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 { DispatchInfo as _DispatchInfo } from './bundleManager/dispatchInfo'; +import * as _PackInfo from './bundleManager/packInfo' + +/** + * Free install bundle manager. + * @namespace freeInstall + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +declare namespace freeInstall { + /** + * Used to set the enumeration value of upgrading for free installation. + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export enum UpgradeFlag { + /** + * Indicates module not need to be upgraded + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + NOT_UPGRADE = 0, + /** + * Indicates single module need to be upgraded + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + SINGLE_UPGRADE = 1, + /** + * Indicates relation module need to be upgraded + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + RELATION_UPGRADE = 2, + } + + /** + * Used to query the enumeration value of bundlePackInfo. + * @enum {number} + * @syscap SystemCapability.BundleManager.BundleFramework + * @systemapi + * @since 9 + */ + export enum BundlePackFlag { + /** + * Query all package information. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + GET_PACK_INFO_ALL = 0x00000000, + /** + * Query package information + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + GET_PACKAGES = 0x00000001, + /** + * Query the brief information of the package + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + GET_BUNDLE_SUMMARY = 0x00000002, + /** + * Query the brief information of the module. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + GET_MODULE_SUMMARY = 0x00000004, + } + + /** + * Sets wether to upgrade the module. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { string } moduleName - Indicates the module name of the application. + * @param { UpgradeFlag } upgradeFlag - Indicates upgradeFlag of the application. + * @param { AsyncCallback } callback - The callback of setting module upgrade flag result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700002 - The specified module name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback) : void; + + /** + * Sets wether to upgrade the module. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { string } moduleName - Indicates the module name of the application. + * @param { UpgradeFlag } upgradeFlag - Indicates upgradeFlag of the application. + * @returns { Promise } - Return the result of setting module upgrade flag. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700002 - The specified module name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise; + + /** + * Checks whether a specified module is removable. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { string } moduleName - Indicates the module name of the application. + * @param { AsyncCallback } callback - The callback of checking module removable result.The result is true if the module is removable, false otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700002 - The specified module name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback): void; + + /** + * Checks whether a specified module is removable. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { string } moduleName - Indicates the module name of the application. + * @returns {Promise} Returns true if the module is removable; returns false otherwise. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @throws { BusinessError } 17700002 - The specified module name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function isHapModuleRemovable(bundleName: string, moduleName: string): Promise; + + /** + * Obtains bundlePackInfo based on bundleName and bundleFlags. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { BundlePackFlag } bundlePackFlag - Indicates the application bundle pack flag to be queried. + * @param { AsyncCallback } callback - The callback of getting the BundlePackInfo object result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: AsyncCallback): void; + + /** + * Obtains bundlePackInfo based on bundleName and bundleFlags. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { BundlePackFlag } bundlePackFlag - Indicates the application bundle pack flag to be queried. + * @returns {Promise} Returns the BundlePackInfo object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 17700001 - The specified bundle name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise; + + /** + * Obtains information about the dispatcher version. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { AsyncCallback } callback - The callback of getting the dispatchInfo object for the current ability result. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function getDispatchInfo(callback: AsyncCallback): void; + + /** + * Obtains information about the dispatcher version. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @returns { Promise } Returns the DispatchInfo object for the current ability. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + function getDispatchInfo(): Promise; + + /** + * The dispatch info class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type DispatchInfo = _DispatchInfo; + + /** + * The bundle pack info class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type BundlePackInfo = _PackInfo.BundlePackInfo; + + /** + * The package info class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type PackageConfig = _PackInfo.PackageConfig; + + /** + * The package summary class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type PackageSummary = _PackInfo.PackageSummary; + + /** + * The bundle summary class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type BundleConfigInfo = _PackInfo.BundleConfigInfo; + + /** + * The extension ability forms class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type ExtensionAbility = _PackInfo.ExtensionAbility; + + /** + * The module summary of a bundle. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type ModuleConfigInfo = _PackInfo.ModuleConfigInfo; + + /** + * The bundle info summary class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type ModuleDistroInfo = _PackInfo.ModuleDistroInfo; + + /** + * The ability info of a module. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type ModuleAbilityInfo = _PackInfo.ModuleAbilityInfo; + + /** + * The form info of an ability. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type AbilityFormInfo = _PackInfo.AbilityFormInfo; + + /** + * The bundle version class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type Version = _PackInfo.Version; + + /** + * The bundle Api version class. + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export type ApiVersion = _PackInfo.ApiVersion; +} + +export default freeInstall; diff --git a/api/@ohos.bundle.innerBundleManager.d.ts b/api/@ohos.bundle.innerBundleManager.d.ts index 9eaaeee19f2a5d289681f7acd18a7e9f9bfcc5ee..f9d0bb358e8951ded4673c798a161dbf28ecbdaf 100644 --- a/api/@ohos.bundle.innerBundleManager.d.ts +++ b/api/@ohos.bundle.innerBundleManager.d.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; -import { BundleStatusCallback as _BundleStatusCallback } from './bundle/bundleStatusCallback'; -import { LauncherAbilityInfo as _LauncherAbilityInfo } from './bundle/launcherAbilityInfo'; -import * as _ShortCutInfo from './bundle/shortcutInfo'; +import { AsyncCallback } from './basic'; +import { BundleStatusCallback } from './bundle/bundleStatusCallback'; +import { LauncherAbilityInfo } from './bundle/launcherAbilityInfo'; +import { ShortcutInfo } from './bundle/shortcutInfo'; /** * inner bundle manager. @@ -25,6 +25,8 @@ import * as _ShortCutInfo from './bundle/shortcutInfo'; * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.launcherBundleManager */ declare namespace innerBundleManager { @@ -38,6 +40,8 @@ declare namespace innerBundleManager { * @return Returns the LauncherAbilityInfo object. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.launcherBundleManager#getLauncherAbilityInfo */ function getLauncherAbilityInfos(bundleName: string, userId: number, callback: AsyncCallback>) : void; function getLauncherAbilityInfos(bundleName: string, userId: number) : Promise>; @@ -52,6 +56,8 @@ declare namespace innerBundleManager { * @return Returns the result or error maeeage. * @permission ohos.permission.LISTEN_BUNDLE_CHANGE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.bundleMonitor#on */ function on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback, callback: AsyncCallback) : void; function on(type:"BundleStatusChange", bundleStatusCallback : BundleStatusCallback): Promise; @@ -65,6 +71,8 @@ declare namespace innerBundleManager { * @return Returns the result or error maeeage. * @permission ohos.permission.LISTEN_BUNDLE_CHANGE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.bundleMonitor#off */ function off(type:"BundleStatusChange", callback: AsyncCallback) : void; function off(type:"BundleStatusChange"): Promise; @@ -78,6 +86,8 @@ declare namespace innerBundleManager { * @return Returns the LauncherAbilityInfo object. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.launcherBundleManager#getAllLauncherAbilityInfos */ function getAllLauncherAbilityInfos(userId: number, callback: AsyncCallback>) : void; function getAllLauncherAbilityInfos(userId: number) : Promise>; @@ -91,45 +101,11 @@ declare namespace innerBundleManager { * @return Returns the LauncherShortcutInfo object. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.launcherBundleManager#getShortcutInfo */ function getShortcutInfos(bundleName :string, callback: AsyncCallback>) : void; function getShortcutInfos(bundleName : string) : Promise>; - - /** - * Contains basic launcher Ability information, which uniquely identifies an LauncherAbilityInfo. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type LauncherAbilityInfo = _LauncherAbilityInfo; - - /** - * Contains basic launcher Ability information, which uniquely identifies a launcher StatusCallback. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type BundleStatusCallback = _BundleStatusCallback; - - /** - * Provides information about a shortcut, including the shortcut ID and label. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - export type ShortcutInfo = _ShortCutInfo.ShortcutInfo; - - /** - * Provides methods for obtaining information about the ability that a shortcut will start, including the target - * bundle name, target module name and ability class name. - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export type ShortcutWant = _ShortCutInfo.ShortcutWant; } export default innerBundleManager; diff --git a/api/@ohos.bundle.installer.d.ts b/api/@ohos.bundle.installer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..854e0b7d311f742e62f2dcb962395f9c14c425cf --- /dev/null +++ b/api/@ohos.bundle.installer.d.ts @@ -0,0 +1,179 @@ +/* + * 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'; + +/** + * Support install, upgrade, remove and recover bundles on the devices. + * @namespace installer + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ +declare namespace installer { + /** + * Obtains the interface used to install bundle. + * @param { AsyncCallback } callback - The callback of BundleInstaller object. + * @throws { BusinessError } 401 - Input parameters check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInstaller(callback: AsyncCallback): void + + /** + * Obtains the interface used to install bundle. + * @param { AsyncCallback } callback - The callback of getting a list of BundleInstaller objects. + * @returns { Promise } BundleInstaller object. + * @throws { BusinessError } 401 - Input parameters check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInstaller(): Promise; + + /** + * Bundle installer interface, include install uninstall recover. + * @interface BundleInstaller + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + interface BundleInstaller { + /** + * Install haps for an application. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { Array } hapFilePaths - Indicates the path where the hap of the application is stored. + * @param { InstallParam } installParam - Indicates other parameters required for the installation. + * @param { AsyncCallback } callback - The callback of installing haps result. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @throws { BusinessError } 17700010 - To parse file of config.json or module.json failed. + * @throws { BusinessError } 17700011 - To verify signature failed. + * @throws { BusinessError } 17700012 - Invalid hap file path or too large file size. + * @throws { BusinessError } 17700015 - Multiple haps have inconsistent configured information. + * @throws { BusinessError } 17700016 - No disk space left for installation. + * @throws { BusinessError } 17700017 - Downgrade installation is prohibited. + * @throws { BusinessError } 17700101 - The system service is excepted. + * @throws { BusinessError } 17700103 - I/O operation is failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + install(hapFilePaths: Array, installParam: InstallParam, callback: AsyncCallback) : void; + + /** + * Uninstall an application. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. + * @param { InstallParam } installParam - Indicates other parameters required for the uninstallation. + * @param { AsyncCallback } callback - The callback of uninstalling application result. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @throws { BusinessError } 17700020 - The specified bundle is pre-installed bundle which cannot be uninstalled. + * @throws { BusinessError } 17700101 - The system service is excepted. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + uninstall(bundleName: string, installParam: InstallParam, callback : AsyncCallback) : void; + + /** + * recover an application. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. + * @param { InstallParam } installParam - Indicates other parameters required for the uninstallation. + * @param { AsyncCallback } callback - The callback of recoverring application result. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback): void; + } + + /** + * Provides parameters required for hashParam. + * @typedef HashParam + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + export interface HashParam { + /** + * Indicates the moduleName + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + moduleName: string; + + /** + * Indicates the hash value + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + hashValue: string; + } + + /** + * Provides parameters required for installing or uninstalling an application. + * @typedef InstallParam + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + export interface InstallParam { + /** + * Indicates the user id + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + userId: number; + + /** + * Indicates the install flag + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + installFlag: number; + + /** + * Indicates whether the param has data + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + isKeepData: boolean; + + /** + * Indicates the hash params + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + hashParams?: Array; + + /** + * Indicates the deadline of the crowdtesting bundle + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + crowdtestDeadline?: number; + } +} + +export default installer; \ No newline at end of file diff --git a/api/@ohos.bundle.launcherBundleManager.d.ts b/api/@ohos.bundle.launcherBundleManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..11759af3a6aad79ab4b0ea75036baf39008cda3a --- /dev/null +++ b/api/@ohos.bundle.launcherBundleManager.d.ts @@ -0,0 +1,147 @@ +/* + * 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 { LauncherAbilityInfo as _LauncherAbilityInfo } from './bundleManager/launcherAbilityInfo'; +import { ShortcutInfo as _ShortcutInfo, ShortcutWant as _ShortcutWant} from './bundleManager/shortcutInfo'; + + +/** + * Launcher bundle manager. + * @namespace launcherBundleManager + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ +declare namespace launcherBundleManager { + /** + * Obtains launcher abilities info based on a given bundleName and userId. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } userId - Indicates the id for the user. + * @param { AsyncCallback> } callback -The callback of the LauncherAbilityInfo object result. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @throws {BusinessError} 801 - Capability not support. + * @throws {BusinessError} 17700001 - The specified bundle name is not found. + * @throws {BusinessError} 17700004 - The specified user id is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + function getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallback>) : void; + + /** + * Obtains launcher abilities info based on a given bundleName and userId. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { number } userId - Indicates the id for the user. + * @returns { Promise> } the LauncherAbilityInfo object. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @throws {BusinessError} 801 - Capability not support. + * @throws {BusinessError} 17700001 - The specified bundle name is not found. + * @throws {BusinessError} 17700004 - The specified user id is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + function getLauncherAbilityInfo(bundleName: string, userId: number) : Promise>; + + /** + * Obtains launcher abilities info based on a given userId. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { number } userId - Indicates the id for the user. + * @param { AsyncCallback> } callback -The callback of the LauncherAbilityInfo object result. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @throws {BusinessError} 801 - Capability not support. + * @throws {BusinessError} 17700004 - The specified user id is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + function getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback>) : void; + + /** + * Obtains launcher abilities info based on a given userId. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { number } userId - Indicates the id for the user. + * @returns { Promise> } the LauncherAbilityInfo object. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @throws {BusinessError} 801 - Capability not support. + * @throws {BusinessError} 17700004 - The specified user id is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + function getAllLauncherAbilityInfo(userId: number) : Promise>; + + /** + * Obtains shortcut info based on a given bundleName. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @param { AsyncCallback> } callback -The callback of the ShortcutInfo object result. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @throws {BusinessError} 801 - Capability not support. + * @throws {BusinessError} 17700001 - The specified bundle name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + function getShortcutInfo(bundleName :string, callback: AsyncCallback>) : void; + + /** + * Obtains shortcut info based on a given bundleName. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the application bundle name to be queried. + * @returns { Promise> } the LauncherShortcutInfo object. + * @throws {BusinessError} 201 - Verify permission denied. + * @throws {BusinessError} 401 - The parameter check failed. + * @throws {BusinessError} 801 - Capability not support. + * @throws {BusinessError} 17700001 - The specified bundle name is not found. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + function getShortcutInfo(bundleName : string) : Promise>; + + /** + * Contains basic launcher Ability information, which uniquely identifies an LauncherAbilityInfo. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + export type LauncherAbilityInfo = _LauncherAbilityInfo; + + /** + * Provides information about a shortcut, including the shortcut ID and label. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + export type ShortcutInfo = _ShortcutInfo; + /** + * Obtains information about the ability that a shortcut will start. + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + export type ShortcutWant = _ShortcutWant; +} + +export default launcherBundleManager; diff --git a/api/@ohos.bundleState.d.ts b/api/@ohos.bundleState.d.ts index 01d6f4c8e3322bd595fcf63efc3f3bf43eb3033a..b2539343d27555c39858a623dd9f5f87021b081a 100644 --- a/api/@ohos.bundleState.d.ts +++ b/api/@ohos.bundleState.d.ts @@ -25,53 +25,57 @@ import { AsyncCallback , Callback} from './basic'; * then returns it to you. * * @since 7 + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics */ declare namespace bundleState { /** * @since 7 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsInfo */ interface BundleStateInfo { /** - * the identifier of BundleStateInfo. + * The identifier of BundleStateInfo. */ id: number; /** - * the total duration, in milliseconds. + * The total duration, in milliseconds. */ abilityInFgTotalTime?: number; /** - * the last time when the application was accessed, in milliseconds. + * 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. + * The last time when the application was visible in the foreground, in milliseconds. */ abilityPrevSeenTime?: number; /** - * the total duration, in milliseconds. + * The total duration, in milliseconds. */ abilitySeenTotalTime?: number; /** - * the bundle name of the application. + * The bundle name of the application. */ bundleName?: string; /** - * the total duration, in milliseconds. + * The total duration, in milliseconds. */ fgAbilityAccessTotalTime?: number; /** - * the last time when the foreground application was accessed, in milliseconds. + * 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, + * 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, + * The time of the last bundle usage record in this {@code BundleActiveInfo} object, * in milliseconds. */ infosEndTime?: number; @@ -83,178 +87,43 @@ declare namespace bundleState { * @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. + * If the bundle names of the two {@link BundleActiveInfo} objects are different. */ merge(toMerge: BundleStateInfo): void; } - /** - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @systemapi Hide this for inner system use. - */ - 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 - * @systemapi Hide this for inner system use. - */ - 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 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @systemapi Hide this for inner system use. - */ - interface BundleActiveEventState { - /** - * the bundle name or system event name. - */ - name: string; - - /** - * the event id. - */ - eventId: number; - - /** - * the the event occurrence number. - */ - count: number; - } - /** * @since 7 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.BundleEvents */ interface BundleActiveState { /** - * the usage priority group of the application. + * The usage priority group of the application. */ appUsagePriorityGroup?: number; /** - * the bundle name. + * The bundle name. */ bundleName?: string; /** - * the shortcut ID. + * The shortcut ID. */ indexOfLink?: string; /** - * the class name. + * The class name. */ nameOfClass?: string; /** - * the time when this state occurred, in milliseconds. + * The time when this state occurred, in milliseconds. */ stateOccurredTime?: number; /** - * the state type. + * The state type. */ stateType?: number; } - /** - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @systemapi Hide this for inner system use. - */ - 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. @@ -265,6 +134,8 @@ declare namespace bundleState { * @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. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.isIdleState */ function isIdleState(bundleName: string, callback: AsyncCallback): void; function isIdleState(bundleName: string): Promise; @@ -278,6 +149,8 @@ declare namespace bundleState { * @since 7 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup * @return Returns the usage priority group of the calling application. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryAppGroup */ function queryAppUsagePriorityGroup(callback: AsyncCallback): void; function queryAppUsagePriorityGroup(): Promise; @@ -285,6 +158,8 @@ declare namespace bundleState { /** * @since 7 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.BundleStatsMap */ interface BundleActiveInfoResponse { [key: string]: BundleStateInfo; @@ -302,6 +177,8 @@ declare namespace bundleState { * @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 BundleActiveInfoResponse} objects containing the usage information about each bundle. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfos */ function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback): void; function queryBundleStateInfos(begin: number, end: number): Promise; @@ -311,6 +188,8 @@ declare namespace bundleState { * * @since 7 * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.IntervalType */ export enum IntervalType { /** @@ -352,6 +231,8 @@ declare namespace bundleState { * @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 list of {@link BundleStateInfo} objects containing the usage information about each bundle. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryBundleStatsInfoByInterval */ function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback>): void; function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise>; @@ -366,6 +247,8 @@ declare namespace bundleState { * @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 list of {@link BundleActiveState} objects containing the state data of all bundles. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryBundleEvents */ function queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; function queryBundleActiveStates(begin: number, end: number): Promise>; @@ -378,146 +261,11 @@ declare namespace bundleState { * @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. + * @deprecated since 9 + * @useinstead ohos.resourceschedule.usageStatistics.queryCurrentBundleEvents */ function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void; function queryCurrentBundleActiveStates(begin: number, end: number): Promise>; - - /** - * Queries recently module usage records. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param maxNum Indicates max record number in result, max value is 1000, default value is 1000. - * @return Returns the {@link BundleActiveModuleInfo} object Array containing the usage data of the modules. - */ - function getRecentlyUsedModules(callback: AsyncCallback>): void; - function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback>): void; - function getRecentlyUsedModules(maxNum?: number): 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 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param bundleName, name of the application. - * @return Returns the usage priority group of the calling application. - */ - function queryAppUsagePriorityGroup(callback: AsyncCallback): void; - function queryAppUsagePriorityGroup(bundleName: string, callback: AsyncCallback): void; - function queryAppUsagePriorityGroup(bundleName?: string): Promise; - - /** - * Declares group type. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @systemapi Hide this for inner system use. - */ - 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 - } - - /** - * set bundle group by bundleName and number. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param bundleName, name of the application. - * @param newGroup,the group of the application whose name is bundleName. - * @return Returns the result of setBundleGroup, true of false. - */ - function setBundleGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback): void; - function setBundleGroup(bundleName: string, newGroup: GroupType): Promise; - - /** - * register callback to service. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @param Callback, callback when application group change,return the BundleActiveGroupCallbackInfo. - * @return Returns BundleActiveGroupCallbackInfo when the group of bundle changed. the result of AsyncCallback is true or false. - */ - function registerGroupCallBack(groupCallback: Callback, callback: AsyncCallback): void; - function registerGroupCallBack(groupCallback: Callback): Promise; - - /** - * unRegister callback from service. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @return Returns the result of unRegisterGroupCallBack, true of false. - */ - function unRegisterGroupCallBack(callback: AsyncCallback): void; - function unRegisterGroupCallBack(): Promise; - - /* - * Queries system event states data within a specified period identified by the start and end time. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @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 BundleActiveEventState} object Array containing the event states data. - */ - function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback>): void; - function queryBundleActiveEventStates(begin: number, end: number): Promise>; - - /** - * Queries app notification number within a specified period identified by the start and end time. - * - * @since 9 - * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App - * @permission ohos.permission.BUNDLE_ACTIVE_INFO - * @systemapi Hide this for inner system use. - * @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 BundleActiveEventState} object Array containing the event states data. - */ - function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback>): void; - function queryAppNotificationNumber(begin: number, end: number): Promise>; } export default bundleState; diff --git a/api/@ohos.continuation.continuationManager.d.ts b/api/@ohos.continuation.continuationManager.d.ts index 9b9cbe3304f0a6cb9c9992cb469fbeee138e1a42..292945f77c38da229171069f95c0934dfd2b4c8d 100644 --- a/api/@ohos.continuation.continuationManager.d.ts +++ b/api/@ohos.continuation.continuationManager.d.ts @@ -30,8 +30,10 @@ 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. * - * @param type deviceConnect. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param type deviceSelected. * @return callback Indicates the information about the selected devices. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16600001 - The system ability work abnormally. * @throws { BusinessError } 16600002 - The specified token or callback has not registered. @@ -39,15 +41,17 @@ declare namespace continuationManager { * @syscap SystemCapability.Ability.DistributedAbilityManager * @since 9 */ - function on(type: "deviceConnect", token: number, callback: Callback>): void; - function off(type: "deviceConnect", token: number): void; + function on(type: "deviceSelected", token: number, callback: Callback>): void; + function off(type: "deviceSelected", token: number): void; /** * Called when devices are disconnected from the continuation manager service. * You can implement your own processing logic in this callback, such as notifying the user of the disconnection. * - * @param type deviceDisconnect. - * @return callback Indicates the ID of the disconnected devices. + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param type deviceUnselected. + * @return callback Indicates the information about the unselected devices. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16600001 - The system ability work abnormally. * @throws { BusinessError } 16600002 - The specified token or callback has not registered. @@ -55,8 +59,8 @@ declare namespace continuationManager { * @syscap SystemCapability.Ability.DistributedAbilityManager * @since 9 */ - function on(type: "deviceDisconnect", token: number, callback: Callback>): void; - function off(type: "deviceDisconnect", token: number): void; + function on(type: "deviceUnselected", token: number, callback: Callback>): void; + function off(type: "deviceUnselected", token: number): void; /** * Called when the user selects a device from the candidate device list. @@ -149,9 +153,11 @@ declare namespace continuationManager { * Registers an ability to be hopped with the continuation manager service and obtains the registration token * assigned to the ability. * + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @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 service is connected. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16600001 - The system ability work abnormally. * @throws { BusinessError } 16600003 - The number of token registration times has reached the upper limit. @@ -166,8 +172,10 @@ declare namespace continuationManager { * Unregisters a specified ability from the continuation manager service based on the token obtained during ability * registration. * + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @param token Indicates the registration token of the ability. * @return callback Indicates the callback to be invoked when the continuation manager service is connected. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16600001 - The system ability work abnormally. * @throws { BusinessError } 16600002 - The specified token or callback has not registered. @@ -180,10 +188,12 @@ declare namespace continuationManager { /** * Updates the connection state of the device where the specified ability is successfully hopped. * + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @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 service is connected. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16600001 - The system ability work abnormally. * @throws { BusinessError } 16600002 - The specified token or callback has not registered. @@ -196,10 +206,12 @@ declare namespace continuationManager { /** * Start to manage the devices that can be selected for continuation. * + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @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 service is connected. + * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 16600001 - The system ability work abnormally. * @throws { BusinessError } 16600002 - The specified token or callback has not registered. diff --git a/api/@ohos.convertxml.d.ts b/api/@ohos.convertxml.d.ts index c4f7dfc141008641bac72b0e0e90451e55cbff0b..bf0cbe1192fa7253dd6ceae318a9644f4003172c 100644 --- a/api/@ohos.convertxml.d.ts +++ b/api/@ohos.convertxml.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -138,16 +138,36 @@ declare namespace xml { elementsKey: string; } + /** + * ConvertXML representation refers to extensible markup language. + * @name ConvertXML + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ class ConvertXML { /** * To convert XML text to JavaScript object. * @since 8 + * @deprecated since 9 + * @useinstead ohos.convertxml.ConvertXML.convertToJSObject * @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; + + /** + * To convert XML text to JavaScript object. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200002 - Invalid xml string. + */ + convertToJSObject(xml: string, options?: ConvertOptions) : Object; } } export default xml; \ No newline at end of file diff --git a/api/@ohos.data.dataShare.d.ts b/api/@ohos.data.dataShare.d.ts index a773ff1954985421401321c39fe28f0b7069676a..2a55be2efcd4e75eeb970441ba5e270b029873a8 100644 --- a/api/@ohos.data.dataShare.d.ts +++ b/api/@ohos.data.dataShare.d.ts @@ -19,119 +19,219 @@ import DataShareResultSet from './@ohos.data.DataShareResultSet'; import dataSharePredicates from './@ohos.data.dataSharePredicates'; import { ValuesBucket } from './@ohos.data.ValuesBucket'; +/** +* This module provides the dataShare capability for consumer. +* @syscap SystemCapability.DistributedDataManager.DataShare.Consumer +* @systemapi +* @StageModelOnly +* @since 9 + */ declare namespace dataShare { /** * Obtains the dataShareHelper. - * @since 9 + * @param {Context} context - Indicates the application context. + * @param {string} uri - Indicates the path of the file to open. + * @param {AsyncCallback} callback - {DataShareHelper}: the dataShareHelper for consumer. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 15700010 - the DataShareHelper is not initialized successfully. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @param context Indicates the application context. - * @param uri Indicates the path of the file to open. - * @return Returns the dataShareHelper. * @StageModelOnly + * @since 9 */ function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback): void; + + /** + * Obtains the dataShareHelper. + * @param {Context} context - Indicates the application context. + * @param {string} uri - Indicates the path of the file to open. + * @returns {Promise} {DataShareHelper}: the dataShareHelper for consumer. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 15700010 - the DataShareHelper is not initialized successfully. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ function createDataShareHelper(context: Context, uri: string): Promise; /** * DataShareHelper - * @since 9 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi * @StageModelOnly + * @since 9 */ interface DataShareHelper { /** * Registers an observer to observe data specified by the given uri. - * @since 9 + * @param {string} type - type must be 'dataChange'. + * @param {string} uri - Indicates the path of the data to operate. + * @param {AsyncCallback} callback - the callback of on. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @param type dataChange. - * @param uri Indicates the path of the data to operate. - * @param callback Indicates the callback when dataChange. - * @return - * @StageModelOnly + * @since 9 */ on(type: 'dataChange', uri: string, callback: AsyncCallback): void; /** * Deregisters an observer used for monitoring data specified by the given uri. - * @since 9 + * @param {string} type - type must be 'dataChange'. + * @param {string} uri - Indicates the path of the data to operate. + * @param {AsyncCallback} callback - the callback of off. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @param type dataChange. - * @param uri Indicates the path of the data to operate. - * @param callback Indicates the registered callback. - * @return - * @StageModelOnly + * @since 9 */ off(type: 'dataChange', uri: string, callback?: AsyncCallback): void; /** * Inserts a single data record into the database. - * @since 9 + * @param {string} uri - Indicates the path of the data to operate. + * @param {ValueBucket} value - Indicates the data record to insert. If this parameter is null, + * a blank row will be inserted. + * @param {AsyncCallback} callback - {number}: the index of the inserted data record. + * @throws {BusinessError} 401 - the parameter check failed. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ insert(uri: string, value: ValuesBucket, callback: AsyncCallback): void; + + /** + * Inserts a single data record into the database. + * @param {string} uri - Indicates the path of the data to operate. + * @param {ValueBucket} value - Indicates the data record to insert. If this parameter is null, + * a blank row will be inserted. + * @returns {Promise} {number}: the index of the inserted data record. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ insert(uri: string, value: ValuesBucket): Promise; /** * Deletes one or more data records from the database. - * @since 9 + * @param {string} uri - Indicates the path of the data to operate. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates filter criteria. + * You should define the processing logic when this parameter is null. + * @param {AsyncCallback} callback - {number}: the number of data records deleted. + * @throws {BusinessError} 401 - the parameter check failed. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Deletes one or more data records from the database. + * @param {string} uri - Indicates the path of the data to operate. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates filter criteria. + * You should define the processing logic when this parameter is null. + * @returns {Promise} {number}: the number of data records deleted. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise; /** * Queries data in the database. + * @param {string} uri - Indicates the path of data to query. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates filter criteria. + * You should define the processing logic when this parameter is null. + * @param {Array} columns - Indicates the columns to query. + * If this parameter is null, all columns are queried. + * @param {AsyncCallback} callback - {DataShareResultSet}: the query result. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly * @since 9 + */ + query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, + callback: AsyncCallback): void; + + /** + * Queries data in the database. + * @param {string} uri - Indicates the path of data to query. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates filter criteria. + * You should define the processing logic when this parameter is null. + * @param {Array} columns - Indicates the columns to query. + * If this parameter is null, all columns are queried. + * @returns {Promise} {DataShareResultSet}: the query result. + * @throws {BusinessError} 401 - the parameter check failed. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ - query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, callback: AsyncCallback): void; - query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array): Promise; + query(uri: string, predicates: dataSharePredicates.DataSharePredicates, + columns: Array): Promise; /** * Updates data records in the database. + * @param {string} uri - Indicates the path of data to update. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates filter criteria. + * You should define the processing logic when this parameter is null. + * @param {ValueBucket} value - Indicates the data to update. This parameter can be null. + * @param {AsyncCallback} callback - {number}: the number of data records updated. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly * @since 9 + */ + update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket, + callback: AsyncCallback): void; + + /** + * Updates data records in the database. + * @param {string} uri - Indicates the path of data to update. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates filter criteria. + * You should define the processing logic when this parameter is null. + * @param {ValueBucket} value - Indicates the data to update. This parameter can be null. + * @returns {Promise} {number}: the number of data records updated. + * @throws {BusinessError} 401 - the parameter check failed. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ - 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 + * @param {string} uri - Indicates the path of the data to operate. + * @param {Array} values - Indicates the data records to insert. + * @param {AsyncCallback} callback - {number}: the number of data records inserted. + * @throws {BusinessError} 401 - the parameter check failed. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ batchInsert(uri: string, values: Array, callback: AsyncCallback): void; + + /** + * Inserts multiple data records into the database. + * @param {string} uri - Indicates the path of the data to operate. + * @param {Array} values - Indicates the data records to insert. + * @returns {Promise} {number}: the number of data records inserted. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ batchInsert(uri: string, values: Array): Promise; /** @@ -140,49 +240,81 @@ declare namespace dataShare { *

          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 + * @param {string} uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. + * @param {AsyncCallback} callback - {string}: the normalized Uri, + * if the DataShare supports uri normalization. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ normalizeUri(uri: string, callback: AsyncCallback): void; + + /** + * 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. + * @param {string} uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. + * @returns {Promise} {string}: the normalized Uri if the DataShare supports uri normalization; + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ normalizeUri(uri: string): Promise; /** * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. - * @since 9 + * @param {string} uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. + * @param {AsyncCallback} callback - {string}: 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. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @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 + * @since 9 */ denormalizeUri(uri: string, callback: AsyncCallback): void; + + /** + * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. + * @param {string} uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. + * @returns {Promise} {string}: 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. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ denormalizeUri(uri: string): Promise; /** * Notifies the registered observers of a change to the data resource specified by Uri. - * @since 9 + * @param {string} uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. + * @param {AsyncCallback} callback - the callback of notifyChange. * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer * @systemapi - * @param uri Indicates the {@link ohos.utils.net.Uri} object to notifyChange. - * @return - * @StageModelOnly + * @since 9 */ notifyChange(uri: string, callback: AsyncCallback): void; + + /** + * Notifies the registered observers of a change to the data resource specified by Uri. + * @param {string} uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. + * @returns {Promise} the promise returned by the function. + * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer + * @systemapi + * @StageModelOnly + * @since 9 + */ notifyChange(uri: string): Promise; } } -export default dataShare; +export default dataShare; \ No newline at end of file diff --git a/api/@ohos.data.distributedData.d.ts b/api/@ohos.data.distributedData.d.ts index e020a0403156886ce840b91c9e0a6fcb6cf666f1..9231cbc643dcd839ff67ccdbdc9a9f4e8ed299ec 100644 --- a/api/@ohos.data.distributedData.d.ts +++ b/api/@ohos.data.distributedData.d.ts @@ -14,51 +14,40 @@ */ import { AsyncCallback, Callback } from './basic'; -import { ValuesBucket } from './@ohos.data.ValuesBucket'; -import dataSharePredicates from './@ohos.data.dataSharePredicates'; -import DataShareResultSet from './@ohos.data.DataShareResultSet'; -import Context from './application/Context'; /** * Providers interfaces to creat a {@link KVManager} istances. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore */ - 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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManagerConfig */ interface KVManagerConfig { /** * Indicates the user information - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ userInfo: UserInfo; /** * Indicates the bundleName - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManagerConfig#bundleName */ 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 - */ - context: Context; } /** @@ -67,24 +56,24 @@ declare namespace distributedData { *

          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 + * @since 7 + * @deprecated since 9 */ interface UserInfo { /** * Indicates the user ID to set - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ userId?: string; /** * Indicates the user type to set - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ userType?: UserType; } @@ -92,72 +81,80 @@ declare namespace distributedData { /** * Enumerates user types. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 */ 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 + * @since 7 + * @deprecated since 9 */ SAME_USER_ID = 0 } /** * KVStore constants - * @since 7 + * * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants */ namespace Constants { /** * max key length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_KEY_LENGTH */ const MAX_KEY_LENGTH = 1024; /** * max value length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_VALUE_LENGTH */ const MAX_VALUE_LENGTH = 4194303; /** * max device coordinate key length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_KEY_LENGTH_DEVICEs */ const MAX_KEY_LENGTH_DEVICE = 896; /** * max store id length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_STORE_ID_LENGTH */ const MAX_STORE_ID_LENGTH = 128; /** * max query length. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_QUERY_LENGTH */ const MAX_QUERY_LENGTH = 512000; /** * max batch operation size. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Constants#MAX_BATCH_SIZE */ const MAX_BATCH_SIZE = 128; } @@ -167,56 +164,63 @@ declare namespace distributedData { * *

          {@code ValueType} is obtained based on the value. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType */ enum ValueType { /** * Indicates that the value type is string. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#STRING */ STRING = 0, /** * Indicates that the value type is int. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#INTEGER */ INTEGER = 1, /** * Indicates that the value type is float. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#FLOAT */ FLOAT = 2, /** * Indicates that the value type is byte array. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueTypeB#YTE_ARRAY * */ BYTE_ARRAY = 3, /** * Indicates that the value type is boolean. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#BOOLEAN * */ BOOLEAN = 4, /** * Indicates that the value type is double. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ValueType#DOUBLE */ DOUBLE = 5 } @@ -224,26 +228,29 @@ declare namespace distributedData { /** * Obtains {@code Value} objects stored in a {@link KVStore} database. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Value */ interface Value { /** * Indicates value type - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A * @see ValueType * @type {number} * @memberof Value + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Value#type */ type: ValueType; /** * Indicates value - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Value#value */ value: Uint8Array | string | number | boolean; } @@ -251,23 +258,26 @@ declare namespace distributedData { /** * Provides key-value pairs stored in the distributed database. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Entry */ interface Entry { /** * Indicates key - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Entry#key */ key: string; /** * Indicates value - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Entry#value */ value: Value; } @@ -278,37 +288,42 @@ declare namespace distributedData { *

          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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification */ interface ChangeNotification { /** * Indicates data addition records. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#insertEntries */ insertEntries: Entry[]; /** * Indicates data update records. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#updateEntries */ updateEntries: Entry[]; /** * Indicates data deletion records. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#deleteEntries */ deleteEntries: Entry[]; /** * Indicates from device id. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.ChangeNotification#deviceId */ deviceId: string; } @@ -316,30 +331,34 @@ declare namespace distributedData { /** * Indicates the database synchronization mode. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode */ enum SyncMode { /** * Indicates that data is only pulled from the remote end. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode#PULL_ONLY */ PULL_ONLY = 0, /** * Indicates that data is only pushed from the local end. - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode#PUSH_ONLY */ 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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SyncMode#PUSH_PULL */ PUSH_PULL = 2 } @@ -347,32 +366,36 @@ declare namespace distributedData { /** * Describes the subscription type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType */ enum SubscribeType { /** * Subscription to local data changes - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_LOCAL */ SUBSCRIBE_TYPE_LOCAL = 0, /** * Subscription to remote data changes - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_REMOTE */ SUBSCRIBE_TYPE_REMOTE = 1, /** * Subscription to both local and remote data changes - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SubscribeType#SUBSCRIBE_TYPE_ALL */ SUBSCRIBE_TYPE_ALL = 2, } @@ -380,32 +403,35 @@ declare namespace distributedData { /** * Describes the {@code KVStore} type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreType */ enum KVStoreType { /** * Device-collaborated database, as specified by {@code DeviceKVStore} - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreType#DEVICE_COLLABORATION */ DEVICE_COLLABORATION = 0, /** * Single-version database, as specified by {@code SingleKVStore} - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreType#SINGLE_VERSION */ SINGLE_VERSION = 1, /** * Multi-version database, as specified by {@code MultiKVStore} - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 */ MULTI_VERSION = 2, } @@ -413,17 +439,18 @@ declare namespace distributedData { /** * Describes the {@code KVStore} type. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel */ enum SecurityLevel { /** * NO_LEVEL: mains not set the security level. * - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 7 + * @deprecated since 9 */ NO_LEVEL = 0, @@ -431,9 +458,9 @@ declare namespace distributedData { * 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 + * @since 7 + * @deprecated since 9 */ S0 = 1, @@ -441,9 +468,10 @@ declare namespace distributedData { * 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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S1 */ S1 = 2, @@ -451,9 +479,10 @@ declare namespace distributedData { * 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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S2 */ S2 = 3, @@ -461,9 +490,10 @@ declare namespace distributedData { * 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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S3 */ S3 = 5, @@ -471,9 +501,10 @@ declare namespace distributedData { * 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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SecurityLevel#S4 */ S4 = 6, } @@ -484,59 +515,67 @@ declare namespace distributedData { *

          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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options */ interface Options { /** * Indicates whether to createa database when the database file does not exist - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#createIfMissing */ createIfMissing?: boolean; /** * Indicates setting whether database files are encrypted - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#encrypt */ encrypt?: boolean; /** * Indicates setting whether to back up database files - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#backup */ 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 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#autoSync */ autoSync?: boolean; /** * Indicates setting the databse type - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#kvStoreType */ kvStoreType?: KVStoreType; /** * Indicates setting the database security level - * @since 7 * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#securityLevel */ securityLevel?: SecurityLevel; /** * Indicates schema object - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore - * @import N/A + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Options#schema */ schema?: Schema; } @@ -546,44 +585,55 @@ declare namespace distributedData { * * 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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema */ class Schema { /** * A constructor used to create a Schema instance. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#constructor */ constructor() /** * Indicates the root json object. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#root */ root: FieldNode; /** * Indicates the string array of json. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#indexes */ indexes: Array; /** * Indicates the mode of schema. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#mode */ mode: number; /** * Indicates the skipsize of schema. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Schema#skip */ skip: number; } @@ -597,17 +647,20 @@ declare namespace distributedData { * *

          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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode */ 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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#constructor */ constructor(name: string) /** @@ -615,31 +668,39 @@ declare namespace distributedData { * *

          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. + * @param child The field node to append. * @returns Returns true if the child node is successfully added to this {@code FieldNode}; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#appendChild */ appendChild(child: FieldNode): boolean; /** * Indicates the default value of fieldnode. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#default */ default: string; /** * Indicates the nullable of database field. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#nullable */ nullable: boolean; /** * Indicates the type of value. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.FieldNode#type */ type: number; } @@ -650,434 +711,494 @@ declare namespace distributedData { *

          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 + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet */ interface KvStoreResultSet { /** * Obtains the number of lines in a result set. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns the number of lines. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getCount */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getPosition */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToFirst */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToLast */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToNext */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToPrevious */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#move */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#moveToPosition */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isFirst */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isLast */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isBeforeFirst */ isBeforeFirst(): boolean; /** * Checks whether the read position is after the last line. * - * @since 8 + * @returns Returns true if the read position is after the last line; returns false otherwise. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @returns Returns true if the read position is after the last line; returns false otherwise. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#isAfterLast */ isAfterLast(): boolean; /** * Obtains a key-value pair. * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core * @returns Returns a key-value pair. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVStoreResultSet#getEntry */ 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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query */ class Query { /** * A constructor used to create a Query instance. - * - * @since 8 + * * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#constructor */ - constructor() + constructor() /** * Resets this {@code Query} object. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A + * * @returns Returns the reset {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#reset */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#equalTo */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#notEqualTo */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#greaterThan */ 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. - */ + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#lessThan + */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#greaterThanOrEqualTo */ 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. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#lessThanOrEqualTo */ 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. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#isNull */ 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. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#inNumber */ 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. + * @returns Returns the {@coed Query} object. * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#inString */ 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. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#notInNumber */ 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. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#notInString */ 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. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#like */ 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. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#unlike */ 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 + * + * @returns Returns the {@coed Query} object. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @returns Returns the {@coed Query} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#and */ and(): Query; /** * Constructs a {@code Query} object with the or condition. - * + * *

          Multiple predicates should be connected using the and or or condition. - * - * @since 8 + * + * @returns Returns the {@coed Query} object. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @returns Returns the {@coed Query} object. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#or */ 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. + * @returns Returns the {@coed Query} object. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#orderByAsc */ 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. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#orderByDesc */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#limit */ 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. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#isNotNull */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#beginGroup */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#endGroup */ 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. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#prefixKey */ 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. + * @throws Throws this exception if input is invalid. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#setSuggestIndex */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#deviceId */ deviceId(deviceId:string):Query; /** @@ -1085,11 +1206,12 @@ declare namespace distributedData { * *

          The String would be parsed to DB query format. * The String length should be no longer than 500kb. - * - * @since 8 + * + * @return String representing this {@code Query}. * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @import N/A - * @return String representing this {@code Query}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.Query#getSqlLike */ getSqlLike():string; } @@ -1102,227 +1224,182 @@ declare namespace distributedData { * 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 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore */ 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}. + * @throws Throws this exception if any of the following errors + * occurs: {@code SERVER_UNAVAILABLE}, {@code IPC_ERROR}, and {@code DB_ERROR}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#put */ 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 - * @systemapi - * @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 + * @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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#delete */ 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 - * @systemapi - * @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; - /** - * Backs up a database in a specified name. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param file Indicates the name that saves the database backup. - */ - backup(file:string, callback: AsyncCallback):void; - backup(file:string): Promise; - - /** - * Restores a database from a specified database file. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param file Indicates the name that saves the database file. - */ - restore(file:string, callback: AsyncCallback):void; - restore(file:string): Promise; - - /** - * Delete a backup files based on a specified name. - * - * @since 9 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param files list Indicates the name that backup file to delete. - */ - deleteBackup(files:Array, callback: AsyncCallback>):void; - deleteBackup(files:Array): Promise>; - - /** - * Registers a {@code KvStoreObserver} for the database. When data in the distributed database changes, the callback in + * 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 + * @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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#on */ 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 + * + * @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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#on */ 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 + * @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}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#off */ - off(event: 'syncComplete', syncCallback?: Callback>): void; + off(event: 'dataChange', listener?: 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#putBatch */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#deleteBatch */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#startTransaction */ startTransaction(callback: AsyncCallback): void; startTransaction(): Promise; /** * Submits a transaction operation in the {@code KvStore} database. - * - * @since 8 - * @syscap SystemCapability.DistributedDataManager.KVStore.Core - * @param callback + * + * @param callback * @throws Throws this exception if a database error occurs. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#commit */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#rollback */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#enableSync */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncRange */ setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback): void; setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise; @@ -1338,49 +1415,53 @@ declare namespace distributedData { * 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 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#get */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getEntries */ getEntries(query: Query, callback: AsyncCallback): void; getEntries(query: Query): Promise; @@ -1391,78 +1472,68 @@ declare namespace distributedData { * {@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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSet */ 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 - * @systemapi - * @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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#closeResultSet */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getResultSize */ 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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#removeDeviceData */ removeDeviceData(deviceId: string, callback: AsyncCallback): void; removeDeviceData(deviceId: string): Promise; @@ -1470,97 +1541,68 @@ declare namespace distributedData { /** * 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}, + * 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}. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#sync */ - on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void; /** - * Register Synchronizes SingleKvStore databases callback. + * 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}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#on */ - off(event:'dataChange', listener?: Callback): void; + on(event: 'syncComplete', syncCallback: 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#off */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#setSyncParam */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.SingleKVStore#getSecurityLevel */ getSecurityLevel(callback: AsyncCallback): void; getSecurityLevel(): Promise; @@ -1568,177 +1610,168 @@ declare namespace distributedData { /** * 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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#get */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getEntries */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSet */ 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. - * @systemapi - * 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 - * @systemapi - * @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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#closeResultSet */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#getResultSize */ getResultSize(deviceId: string, query: Query, callback: AsyncCallback): void; getResultSize(deviceId: string, query: Query): Promise; @@ -1747,107 +1780,77 @@ declare namespace distributedData { * 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#removeDeviceData */ 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 + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC * @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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#sync */ - sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; + sync(deviceIds: string[], 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}. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#on */ - on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + on(event: 'syncComplete', syncCallback: Callback>): void; /** - * Unsubscribes from the DeviceKVStore database based on the specified subscribeType and {@code KvStoreObserver}. + * UnRegister Synchronizes DeviceKVStore databases callback. * - * @since 9 + * @throws Throws this exception if no DeviceKVStore database is available. * @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. + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.DeviceKVStore#off */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore#createKVManager */ function createKVManager(config: KVManagerConfig, callback: AsyncCallback): void; function createKVManager(config: KVManagerConfig): Promise; @@ -1855,23 +1858,26 @@ declare namespace distributedData { /** * 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 + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager */ 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#getKVStore */ getKVStore(storeId: string, options: Options): Promise; getKVStore(storeId: string, options: Options, callback: AsyncCallback): void; @@ -1886,14 +1892,16 @@ declare namespace distributedData { * 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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#closeKVStore */ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback): void; closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise; @@ -1905,13 +1913,16 @@ declare namespace distributedData { * *

          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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#deleteKVStore */ deleteKVStore(appId: string, storeId: string, callback: AsyncCallback): void; deleteKVStore(appId: string, storeId: string): Promise; @@ -1920,12 +1931,14 @@ declare namespace distributedData { * 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. + * @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}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#getAllKVStoreId */ getAllKVStoreId(appId: string, callback: AsyncCallback): void; getAllKVStoreId(appId: string): Promise; @@ -1933,20 +1946,24 @@ declare namespace distributedData { /** * 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#on */ 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. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.distributedKVStore.KVManager#off */ off(event: 'distributedDataServiceDie', deathCallback?: Callback): void; } diff --git a/api/@ohos.data.distributedDataObject.d.ts b/api/@ohos.data.distributedDataObject.d.ts index ac9d6683f1bfa88b7ca9f9a398a471afa948cb91..c42521376c48a3284cc1256d199a18cd15387bfc 100644 --- a/api/@ohos.data.distributedDataObject.d.ts +++ b/api/@ohos.data.distributedDataObject.d.ts @@ -14,44 +14,68 @@ */ import {AsyncCallback, Callback} from './basic'; +import Context from './application/Context'; /** - * Provides interfaces to sync distributed object + * Provides interfaces to sync distributed object. * - * @name distributedDataObject - * @since 8 * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 8 */ declare namespace distributedDataObject { + /** - * Create distributed object + * Create distributed object. * - * @param source Init data of distributed object - * @return Returns the distributed object + * @param {object} source - source Init data of distributed object. + * @returns {DistributedObject} - return the distributed object. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.create */ function createDistributedObject(source: object): DistributedObject; /** - * Generate a random sessionId + * Create distributed object. * - * @return Returns the random sessionId + * @param {Context} context - Indicates the application context. + * @param {object} source - source Init data of distributed object. + * @returns {DistributedObjectV9} - return the distributed object. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + function create(context: Context, source: object): DistributedObjectV9; + + /** + * Generate a random sessionId. + * + * @returns {string} - return generated sessionId. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 */ function genSessionId(): string; /** + * The response of save. + * Contains the parameter information of the save object. + * + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @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; @@ -60,16 +84,24 @@ declare namespace distributedDataObject { * deviceid that data saved * data is "local", means save in local device * otherwise, means the networkId of device + * * @since 9 */ deviceId: string; } /** + * The response of revokeSave. + * Contains the sessionId of the changed object. + * + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 9 */ interface RevokeSaveSuccessResponse { + /** + * The sessionId of the changed object. + * * @since 9 */ sessionId: string; @@ -80,76 +112,262 @@ declare namespace distributedDataObject { * * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.DistributedObjectV9 */ 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 + * @param {string} sessionId - sessionId The sessionId to be joined, if empty, leave all session. + * @returns {boolean} - return a result of function. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.DistributedObjectV9.setSessionId */ setSessionId(sessionId?: string): boolean; /** * On watch of change - * - * @param callback The callback of change + * + * @param {string} type - event type, fixed as' change ', indicates data change. + * @param {Callback<{sessionId: string, fields: Array}>} callback + * indicates the observer of object data changed. + * {string} sessionId - the sessionId of the changed object. + * {Array} fields - changed data. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.DistributedObjectV9.on */ 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 + * + * @param {string} type - event type, fixed as' change ', indicates data change. + * @param {Callback<{sessionId: string, fields: Array}>} callback + * indicates the observer of object data changed. + * {string} sessionId - the sessionId of the changed object. + * {Array} fields - changed data. + * callback If not null, off the callback, if undefined, off all callbacks. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.DistributedObjectV9.off */ 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 + * + * @param {string} type - event type, fixed as' status', indicates the online and offline of the object. + * @param {Callback<{sessionId: string, networkId: string, status: 'online' | 'offline'}>} callback + * indicates the observer of object status changed. + * {string} sessionId - the sessionId of the changed object. + * {string} networkId - networkId of the changed device. + * {string} 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. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.DistributedObjectV9.on */ - on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' | 'offline' }>): void; + 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 + * + * @param {string} type - event type, fixed as' status', indicates the online and offline of the object. + * @param {Callback<{sessionId: string, networkId: string, status: 'online' | 'offline'}>} callback + * Indicates the observer of object status changed. + * {string} sessionId - the sessionId of the changed object. + * {string} networkId - networkId of the changed device. + * {string} 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. + * callback If not null, off the callback, if undefined, off all callbacks. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 8 + * @deprecated since 9 + * @useinstead ohos.distributedDataObject.DistributedObjectV9.off + */ + off(type: 'status', + callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' | 'offline' }>): void; + } + + /** + * Object create by {@link create}. + * + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + interface DistributedObjectV9 { + + /* + * Change object session. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @param {string} sessionId - sessionId The sessionId to be joined, if empty, leave all session. + * @param {AsyncCallback} callback - the callback of setSessionId. + * @throws {BusinessError} 201 - the permissions check failed. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 15400001 - create table failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + setSessionId(sessionId: string, callback: AsyncCallback): void; + setSessionId(callback: AsyncCallback): void; + + /* + * Change object session. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC. + * @param {string} sessionId - sessionId The sessionId to be joined, if empty, leave all session. + * @returns {Promise} - the promise returned by the function. + * @throws {BusinessError} 201 - the permissions check failed. + * @throws {BusinessError} 401 - the parameter check failed. + * @throws {BusinessError} 15400001 - create table failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 */ - off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' | 'offline' }>): void; + setSessionId(sessionId?: string): Promise; + + /** + * On watch of change. + * + * @param {string} type - event type, fixed as' change ', indicates data change. + * @param {Callback<{sessionId: string, fields: Array}>} callback + * indicates the observer of object data changed. + * {string} sessionId - the sessionId of the changed object. + * {Array} fields - changed data. + * sessionId the sessionId of the changed object. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + on(type: 'change', callback: Callback<{ sessionId: string, fields: Array }>): 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 + * Off watch of change. + * + * @param {string} type - event type, fixed as' change ', indicates data change. + * @param {Callback<{sessionId: string, fields: Array}>} callback + * indicates the observer of object data changed. + * {string} sessionId - the sessionId of the changed object. + * {Array} fields - changed data. + * callback If not null, off the callback, if undefined, off all callbacks. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array }>): void; + + /** + * On watch of status. + * + * @param {string} type - event type, fixed as' status', indicates the online and offline of the object. + * @param {Callback<{ sessionId: string, networkId: string, status: 'online' | 'offline' }>} callback + * indicates the observer of object status changed. + * {string} sessionId - the sessionId of the changed object. + * {string} networkId - networkId of the changed device. + * {string} 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. + * 'restored' The object restored success. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + on(type: 'status', + callback: Callback<{ sessionId: string, networkId: string, status: 'online' | 'offline' }>): void; + + /** + * Off watch of status. * - * 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 {string} type - event type, fixed as' status', indicates the online and offline of the object. + * @param {Callback<{sessionId: string, networkId: string, status: 'online' | 'offline'}>} callback + * Indicates the observer of object status changed. + * {string} sessionId - the sessionId of the changed object. + * {string} networkId - networkId of the changed device. + * {string} 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. + * callback If not null, off the callback, if undefined, off all callbacks. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ + 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 * - * @param deviceId Indicates the device that will resume the object data + * 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 {string} deviceId - Indicates the device that will resume the object data. + * @param {AsyncCallback} callback + * {SaveSuccessResponse}: the response of save. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 9 */ save(deviceId: string, callback: AsyncCallback): 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 {string} deviceId - Indicates the device that will resume the object data. + * @returns {Promise} {SaveSuccessResponse}: the response of save. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ 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 + * 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. - * + * + * @param {AsyncCallback} callback + * {RevokeSaveSuccessResponse}: the response of revokeSave. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject * @since 9 */ revokeSave(callback: AsyncCallback): void; + + /** + * 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. + * + * @returns {Promise} {RevokeSaveSuccessResponse}: the response of revokeSave. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.DataObject.DistributedObject + * @since 9 + */ revokeSave(): Promise; } } diff --git a/api/@ohos.data.distributedKVStore.d.ts b/api/@ohos.data.distributedKVStore.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7eb043446415cfdd5d39aaa72dd15cab7a3e32e7 --- /dev/null +++ b/api/@ohos.data.distributedKVStore.d.ts @@ -0,0 +1,2149 @@ +/* + * 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 { ValuesBucket } from './@ohos.data.ValuesBucket'; +import dataSharePredicates from './@ohos.data.dataSharePredicates'; +import Context from './application/Context'; + +/** + * Provider interfaces to create a {@link KVManager} istances. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ +declare namespace distributedKVStore { + /** + * Provides configuration information to create a {@link KVManager} instance, + * which includes the caller's package name and ability or hap context. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface KVManagerConfig { + /** + * Indicates the bundleName + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + bundleName: string; + + /** + * Indicates the ability or hap context + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @Note: if swap the area, you should close all the KV store and use the new Context to create the KVManager + * @since 9 + */ + context: Context; + } + + /** + * KVStore constants + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + namespace Constants { + /** + * Max key length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_KEY_LENGTH = 1024; + + /** + * Max value length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_VALUE_LENGTH = 4194303; + + /** + * Max device coordinate key length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_KEY_LENGTH_DEVICE = 896; + + /** + * Max store id length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_STORE_ID_LENGTH = 128; + + /** + * Max query length. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_QUERY_LENGTH = 512000; + + /** + * Max batch operation size. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + const MAX_BATCH_SIZE = 128; + } + + /** + * Indicates the {@code ValueType}. + * + *

          {@code ValueType} is obtained based on the value. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum ValueType { + /** + * Indicates that the value type is string. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + STRING, + + /** + * Indicates that the value type is int. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + INTEGER, + + /** + * Indicates that the value type is float. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + FLOAT, + + /** + * Indicates that the value type is byte array. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + * */ + BYTE_ARRAY, + + /** + * Indicates that the value type is boolean. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + * */ + BOOLEAN, + + /** + * Indicates that the value type is double. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + DOUBLE, + } + + /** + * Obtains {@code Value} objects stored in a {@link SingleKVStore} or {@link DeviceKVStore} database. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface Value { + /** + * Indicates the value type + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @see ValueType + * @since 9 + */ + type: ValueType; + /** + * Indicates the value + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + value: Uint8Array | string | number | boolean; + } + + /** + * Provides key-value pairs stored in the distributedKVStore. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface Entry { + /** + * Indicates the key + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + key: string; + /** + * Indicates the value + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + value: Value; + } + + /** + * Receive notifications of all data changes, including data insertion, update, and deletion. + * + *

          If you have subscribed to {@code SingleKVStore} or {@code DeviceKVStore}, you will receive + * data change notifications and obtain the changed data from the parameters in callback methods + * upon data insertion, update or deletion. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface ChangeNotification { + /** + * Indicates data insertion records. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + insertEntries: Entry[]; + /** + * Indicates data update records. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + updateEntries: Entry[]; + /** + * Indicates data deletion records. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteEntries: Entry[]; + /** + * Indicates the device id which brings the data change. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deviceId: string; + } + + /** + * Indicates the database synchronization mode. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum SyncMode { + /** + * Indicates that data is only pulled from the remote end. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + PULL_ONLY, + /** + * Indicates that data is only pushed from the local end. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + PUSH_ONLY, + /** + * Indicates that data is pushed from the local end, and then pulled from the remote end. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + PUSH_PULL, + } + + /** + * Describes the subscription type. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum SubscribeType { + /** + * Subscription to local data changes + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SUBSCRIBE_TYPE_LOCAL, + + /** + * Subscription to remote data changes + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SUBSCRIBE_TYPE_REMOTE, + + /** + * Subscription to both local and remote data changes + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SUBSCRIBE_TYPE_ALL, + } + + /** + * Describes the KVStore type. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum KVStoreType { + /** + * Device-collaborated database, as specified by {@code DeviceKVStore} + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + DEVICE_COLLABORATION, + + /** + * Single-version database, as specified by {@code SingleKVStore} + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + SINGLE_VERSION, + } + + /** + * Describes the KVStore security level. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enum SecurityLevel { + /** + * S1: means the db is in the low security level + * There are some low impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S1, + + /** + * S2: means the db is in the middle security level + * There are some major impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S2, + + /** + * S3: means the db is in the high security level + * There are some severity impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S3, + + /** + * S4: means the db is in the critical security level + * There are some critical impact when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + S4, + } + + /** + * Provides configuration options to create a {@code SingleKVStore} or {@code DeviceKVStore}. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface Options { + /** + * Indicates whether to create a database when the database file does not exist + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + createIfMissing?: boolean; + /** + * Indicates whether database files to be encrypted + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + encrypt?: boolean; + /** + * Indicates whether to back up database files + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + backup?: boolean; + /** + * Indicates whether database files are automatically synchronized + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + autoSync?: boolean; + /** + * Indicates the database type + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + kvStoreType?: KVStoreType; + /** + * Indicates the database security level + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + securityLevel: SecurityLevel; + /** + * Indicates the database schema + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + schema?: Schema; + } + + /** + * Represents the database schema. + * + * You can set the schema object in options when create or open the database. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + class Schema { + /** + * A constructor used to create a Schema instance. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + constructor() + /** + * Indicates the root json object. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + root: FieldNode; + /** + * Indicates the string array of json. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + indexes: Array; + /** + * Indicates the mode of schema. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + mode: number; + /** + * Indicates the skip size of schema. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + skip: number; + } + + /** + * Represents a node of a {@link Schema} instance. + * + *

          With a {@link Schema} instance, you can define the value fields which stored in the 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}. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + class FieldNode { + /** + * A constructor used to create a FieldNode instance with the specified field. + * name Indicates the field node name. + * + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + constructor(name: string) + /** + * Adds a child node to this {@code FieldNode}. + * + *

          Add a child node to makes this node a non-leaf node and field value will be ignored if it has a child node. + * + * @param {FieldNode} child - The field node to append. + * @returns Returns true if the child node is successfully added to this {@code FieldNode} and false otherwise. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + appendChild(child: FieldNode): boolean; + /** + * Indicates the default value of field node. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + default: string; + /** + * Indicates the nullable of database field. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + nullable: boolean; + /** + * Indicates the type of value. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + type: number; + } + + /** + * Provides methods to operate the result set of the {@code SingleKVStore} or {@code DeviceKVStore} database. + * + *

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

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

          If the result set is empty, false is returned. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @returns Returns true if the operation succeeds; return false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToPrevious(): boolean; + /** + * Moves the read position by a relative offset to the current position. + * + * @param {number} 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. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + move(offset: number): boolean; + /** + * Moves the read position from 0 to an absolute position. + * + * @param {number} position - Indicates the absolute position. + * @returns Returns true if the operation succeeds; return false otherwise. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + moveToPosition(position: number): boolean; + /** + * Checks whether the read position is the first line. + * + * @returns Returns true if the read position is the first line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isFirst(): boolean; + /** + * Checks whether the read position is the last line. + * + * @returns Returns true if the read position is the last line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isLast(): boolean; + /** + * Checks whether the read position is before the last line. + * + * @returns Returns true if the read position is before the first line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isBeforeFirst(): boolean; + /** + * Checks whether the read position is after the last line. + * + * @returns Returns true if the read position is after the last line; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + isAfterLast(): boolean; + /** + * Obtains a key-value pair. + * + * @returns Returns a key-value pair. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntry(): Entry; + } + + /** + * Represents a database query using predicates. + * + *

          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 to add predicates to the {@code Query} instance. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + class Query { + /** + * A constructor used to create a Query instance. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + constructor() + /** + * Resets this {@code Query} object. + * + * @returns Returns the reset {@code Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + reset(): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is equal to the specified long value. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string|boolean} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string|boolean} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string|boolean} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number|string} value - Indicates the value to be compared. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + lessThanOrEqualTo(field: string, value: number | string): Query; + /** + * Constructs a {@code Query} object to query entries with the specified field whose value is null. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number[]} valueList - Indicates the int value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string[]} valueList - Indicates the string value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {number[]} valueList - Indicates the int value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string[]} valueList - Indicates the string value list. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string} value - Indicates the string value. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @param {string} value - Indicates the string value. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + and(): Query; + /** + * Constructs a {@code Query} object with the or condition. + * + *

          Multiple predicates should be connected using the and or or condition. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + or(): Query; + /** + * Constructs a {@code Query} object to sort the query results in ascending order. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + orderByAsc(field: string): Query; + /** + * Constructs a {@code Query} object to sort the query results in descending order. + * + * @param {string} field - Indicates the field, which must start with $. and cannot contain ^. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + orderByDesc(field: string): Query; + /** + * Constructs a {@code Query} object to specify the number of results and the start position. + * + * @param {number} total - Indicates the number of results. + * @param {number} offset - Indicates the start position. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + limit(total: number, offset: number): Query; + /** + * Creates a {@code Query} condition with a specified field that is not null. + * + * @param {string} field - Indicates the specified field. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @returns Returns the {@coed Query} object. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + endGroup(): Query; + /** + * Creates a query condition with a specified key prefix. + * + * @param {string} prefix - Indicates the specified key prefix. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + prefixKey(prefix: string): Query; + /** + * Sets a specified index that will be preferentially used for query. + * + * @param {string} index - Indicates the index to set. + * @returns Returns the {@coed Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSuggestIndex(index: string): Query; + /** + * Add device ID key prefix.Used by {@code DeviceKVStore}. + * + * @param {string} deviceId - Specify device id to query from. + * @return Returns the {@code Query} object with device ID prefix added. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + 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. + * + * @return String representing this {@code Query}. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getSqlLike():string; + } + + /** + * 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. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface SingleKVStore { + /** + * Writes a key-value pair of the string type into the {@code SingleKVStore} database. + * + *

          If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param {Uint8Array|string|number|boolean} value - Indicates the value to be inserted. + * @param {AsyncCallback} callback - the callback of put. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback): void; + + /** + * Writes a key-value pair of the string type into the {@code SingleKVStore} database. + * + *

          If you do not want to synchronize this key-value pair to other devices, set the write option in the local database. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param {Uint8Array|string|number|boolean} value - Indicates the value to be inserted. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + put(key: string, value: Uint8Array | string | number | boolean): Promise; + + /** + * Inserts key-value pairs into the {@code SingleKVStore} database in batches. + * + * @param {Entry[]} entries - Indicates the key-value pairs to be inserted in batches. + * @param {AsyncCallback} callback - the callback of putBatch. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + putBatch(entries: Entry[], callback: AsyncCallback): void; + + /** + * Inserts key-value pairs into the {@code SingleKVStore} database in batches. + * + * @param {Entry[]} entries - Indicates the key-value pairs to be inserted in batches. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + putBatch(entries: Entry[]): Promise; + + /** + * Writes values of ValuesBucket type into the {@code SingleKVStore} database. + * + * @param {Array} value - Indicates the ValuesBucket array to be inserted. + * @param {AsyncCallback} callback - the callback of putBatch. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @systemapi + * @since 9 + */ + putBatch(value: Array, callback: AsyncCallback): void; + + /** + * Writes values of ValuesBucket type into the {@code SingleKVStore} database. + * + * @param {Array} value - Indicates the ValuesBucket array to be inserted. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @systemapi + * @since 9 + */ + putBatch(value: Array): Promise; + + /** + * Deletes the key-value pair based on a specified key. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @param {AsyncCallback} callback - the callback of delete. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + delete(key: string, callback: AsyncCallback): void; + + /** + * Deletes the key-value pair based on a specified key. + * + * @param {string} key - Indicates the key. Length must be less than {@code MAX_KEY_LENGTH}. + * Spaces before and after the key will be cleared. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + delete(key: string): Promise; + + /** + * Deletes the key-value pairs based on the dataSharePredicates. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @param {AsyncCallback} callback - the callback of delete. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + delete(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback); + + /** + * Deletes the key-value pairs based on the dataSharePredicates. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + delete(predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Deletes key-value pairs in batches from the {@code SingleKVStore} database. + * + * @param {string[]} keys - Indicates the key-value pairs to be deleted in batches. + * @param {AsyncCallback} callback - the callback of deleteBatch. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBatch(keys: string[], callback: AsyncCallback): void; + + /** + * Deletes key-value pairs in batches from the {@code SingleKVStore} database. + * + * @param {string[]} keys - Indicates the key-value pairs to be deleted in batches. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when delete data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBatch(keys: string[]): Promise; + + /** + * Removes data of the specified device from 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. + * + * @param {string} deviceId - Identifies the device whose data is to be removed and the value cannot be the current device ID. + * @param {AsyncCallback} callback - the callback of removeDeviceData. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + removeDeviceData(deviceId: string, callback: AsyncCallback): void; + + /** + * Removes data of the specified device from 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. + * + * @param {string} deviceId - Identifies the device whose data is to be removed and the value cannot be the current device ID. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + removeDeviceData(deviceId: string): Promise; + + /** + * Obtains the value of a specified key. + * + * @param {string} key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @param {AsyncCallback} callback - + * {Uint8Array|string|boolean|number}: the returned value specified by the key. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + get(key: string, callback: AsyncCallback): void; + + /** + * Obtains the value of a specified key. + * + * @param {string} key - Indicates the key. The length must be less than {@code MAX_KEY_LENGTH}. + * @returns {Promise} + * {Uint8Array|string|boolean|number}: the returned value specified by the key. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + get(key: string): Promise; + + /** + * Obtains all key-value pairs that match a specified key prefix. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + \* @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * that match the specified key prefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains all key-value pairs that match a specified key prefix. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {Entry[]}: the list of all key-value pairs that match the + * specified key prefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(keyPrefix: string): Promise; + + /** + * Obtains the list of key-value pairs matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * matching the specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(query: Query, callback: AsyncCallback): void; + + /** + * Obtains the list of key-value pairs matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {Entry[]}: the list of all key-value pairs matching the + * specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getEntries(query: Query): Promise; + + /** + * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} + * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} + * 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. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains the result set with a specified prefix from a {@code SingleKVStore} database. The {@code KVStoreResultSet} + * object can be used to query all key-value pairs that meet the search criteria. Each {@code SingleKVStore} + * 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. + * + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(keyPrefix: string): Promise; + + /** + * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(query: Query, callback: AsyncCallback): void; + + /** + * Obtains the {@code KVStoreResultSet} object matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSet(query: Query): Promise; + + /** + * Obtains the KVStoreResultSet object matching the specified predicate object. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the datasharePredicates. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Obtains the KVStoreResultSet object matching the specified predicate object. + * + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the datasharePredicates. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Closes a {@code KVStoreResultSet} object returned by getResultSet method. + * + * @param {KVStoreResultSet} resultSet - Indicates the {@code KVStoreResultSet} object to close. + * @param {AsyncCallback} callback - the callback of closeResultSet. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeResultSet(resultSet: KVStoreResultSet, callback: AsyncCallback): void; + + /** + * Closes a {@code KVStoreResultSet} object returned by getResultSet method. + * + * @param {KVStoreResultSet} resultSet - Indicates the {@code KVStoreResultSet} object to close. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeResultSet(resultSet: KVStoreResultSet): Promise; + + /** + * Obtains the number of results matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {number}: the number of results matching the + * specified {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSize(query: Query, callback: AsyncCallback): void; + + /** + * Obtains the number of results matching the specified {@code Query} object. + * + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {number}: the number of results matching the specified + * {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getResultSize(query: Query): Promise; + + /** + * Backs up a database in the specified filename. + * + * @param {string} file - Indicates the database backup filename. + * @param {AsyncCallback} callback - the callback of backup. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + backup(file:string, callback: AsyncCallback):void; + + /** + * Backs up a database in the specified filename. + * + * @param {string} file - Indicates the database backup filename. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + backup(file:string): Promise; + + /** + * Restores a database from a specified database file. + * + * @param {string} file - Indicates the database backup filename. + * @param {AsyncCallback} callback - the callback of restore. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + restore(file:string, callback: AsyncCallback):void; + + /** + * Restores a database from a specified database file. + * + * @param {string} file - Indicates the database backup filename. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + restore(file:string): Promise; + + /** + * Delete database backup files based on the specified filenames. + * + * @param {Array} files - Indicates the backup filenames to be deleted. + * @param {AsyncCallback>} callback - {Array<[string, number]>}: + * the list of backup file and it's corresponding delete result which 0 means delete success + * and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBackup(files:Array, callback: AsyncCallback>):void; + + /** + * Delete database backup files based on the specified filenames. + * + * @param {Array} files - Indicates the backup filenames to be deleted. + * @returns {Promise>} {Array<[string, number]>}: the list of backup + * file and it's corresponding delete result which 0 means delete success and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteBackup(files:Array): Promise>; + + /** + * Starts a transaction operation in the {@code SingleKVStore} database. + * + *

          After the database transaction is started, you can submit or roll back the operation. + * + * @param {AsyncCallback} callback - the callback of startTransaction. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + startTransaction(callback: AsyncCallback): void; + + /** + * Starts a transaction operation in the {@code SingleKVStore} database. + * + *

          After the database transaction is started, you can submit or roll back the operation. + * + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + startTransaction(): Promise; + + /** + * Submits a transaction operation in the {@code SingleKVStore} database. + * + * @param {AsyncCallback} callback - the callback of commit. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + commit(callback: AsyncCallback): void; + + /** + * Submits a transaction operation in the {@code SingleKVStore} database. + * + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + commit(): Promise; + + /** + * Rolls back a transaction operation in the {@code SingleKVStore} database. + * + * @param {AsyncCallback} callback - the callback of rollback. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + rollback(callback: AsyncCallback): void; + + /** + * Rolls back a transaction operation in the {@code SingleKVStore} database. + * + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + rollback(): Promise; + + /** + * Sets whether to enable synchronization. + * + * @param {boolean} enabled - Specifies whether to enable synchronization. The value true + * means to enable synchronization, and false means the opposite. + * @param {AsyncCallback} callback - the callback of enableSync. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enableSync(enabled: boolean, callback: AsyncCallback): void; + + /** + * Sets whether to enable synchronization. + * + * @param {boolean} enabled - Specifies whether to enable synchronization. The value true + * means to enable synchronization, and false means the opposite. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + enableSync(enabled: boolean): Promise; + + /** + * Sets synchronization range labels. + * + *

          The labels determine the devices with which data will be synchronized. + * + * @param {string[]} localLabels - Indicates the synchronization labels of the local device. + * @param {string[]} remoteSupportLabels - Indicates the labels of the devices with which + * data will be synchronized. + * @param {AsyncCallback} callback - the callback of setSyncRange. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback): void; + + /** + * Sets synchronization range labels. + * + *

          The labels determine the devices with which data will be synchronized. + * + * @param {string[]} localLabels - Indicates the synchronization labels of the local device. + * @param {string[]} remoteSupportLabels - Indicates the labels of the devices with which + * data will be synchronized. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise; + + /** + * Sets the default delay allowed for database synchronization + * + * @param {number} defaultAllowedDelayMs - Indicates the default delay allowed for the + * database synchronization, in milliseconds. + * @param {AsyncCallback} callback - the callback of setSyncParam. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback): void; + + /** + * Sets the default delay allowed for database synchronization + * + * @param {number} defaultAllowedDelayMs - Indicates the default delay allowed for the + * database synchronization, in milliseconds. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + setSyncParam(defaultAllowedDelayMs: number): Promise; + + /** + * Synchronizes the database to the specified devices with the specified delay allowed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string[]} deviceIds - Indicates the list of devices to which to synchronize the database. + * @param {SyncMode} mode - Indicates the synchronization mode. The value can be {@code PUSH}, + * {@code PULL}, or {@code PUSH_PULL}. + * @param {number} delayMs - Indicates the delay allowed for the synchronization, in milliseconds. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the database not exist when sync data. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void + + /** + * Synchronizes the database to the specified devices with the specified delay allowed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string[]} deviceIds - Indicates the list of devices to which to synchronize the database. + * @param {Query} query - Indicates the {@code Query} object. + * @param {SyncMode} mode - Indicates the synchronization mode. The value can be {@code PUSH}, + * {@code PULL}, or {@code PUSH_PULL}. + * @param {number} delayMs - Indicates the delay allowed for the synchronization, in milliseconds. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the database not exist when sync data. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void; + + /** + * Register a callback to the database and when data in the distributed database has changed, + * the callback will be invoked. + * + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@code SubscribeType}. + * @param {Callback} listener - {ChangeNotification}: the {@code ChangeNotification} + * object indicates the data change events in the distributed database. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100001 - if the database has been subscribed over the max subscription time limit. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + on(event: 'dataChange', type: SubscribeType, listener: Callback): void; + + /** + * Register a databases synchronization callback to the database. + *

          Sync result is returned through asynchronous callback. + * + * @param {Callback>} syncCallback - {Array<[string, number]>}: the + * deviceId and it's corresponding synchronization result which 0 means synchronization success + * and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + on(event: 'syncComplete', syncCallback: Callback>): void; + + /** + * Unsubscribe from the SingleKVStore database based on the specified subscribeType and listener. + * + * @param {Callback} listener - {ChangeNotification}: the {@code ChangeNotification} + * object indicates the data change events in the distributed database. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + off(event:'dataChange', listener?: Callback): void; + + /** + * Unregister the database synchronization callback. + * + * @param {Callback>} syncCallback - {Array<[string, number]>}: the + * deviceId and it's corresponding synchronization result which 0 means synchronization success + * and otherwise failed. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + off(event: 'syncComplete', syncCallback?: Callback>): void; + + /** + * Get the security level of the database. + * + * @param {AsyncCallback} callback - {SecurityLevel}: the {@code SecurityLevel} + * object indicates the security level of the database. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getSecurityLevel(callback: AsyncCallback): void; + + /** + * Get the security level of the database. + * + * @returns {Promise} {SecurityLevel}: the {@code SecurityLevel} object indicates + * the security level of the database. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getSecurityLevel(): Promise; + } + + /** + * Provides methods related to device-collaboration distributed databases. + * + *

          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. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + interface DeviceKVStore extends SingleKVStore { + /** + * Obtains the {@code String} value matching a specified device ID and key. + * + * @param {string} deviceId - Indicates the device to be queried. + * @param {string} key - Indicates the key of the value to be queried. + * @param {AsyncCallback} callback - + * {boolean|string|number|Uint8Array}: the returned value specified by the deviceId and key. + * @return Returns the value matching the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + get(deviceId: string, key: string, callback: AsyncCallback): void; + + /** + * Obtains the {@code String} value matching a specified device ID and key. + * + * @param {string} deviceId - Indicates the device to be queried. + * @param {string} key - Indicates the key of the value to be queried. + * @returns {Promise} + * {Uint8Array|string|boolean|number}: the returned value specified by the deviceId and key. + * @return Returns the value matching the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100004 - if the data not exist when query data. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + get(deviceId: string, key: string): Promise; + + /** + * Obtains all key-value pairs matching a specified device ID and key prefix. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * that match the specified deviceId and key prefix. + * @returns Returns the list of all key-value pairs meeting the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; + + /** + * Obtains all key-value pairs matching a specified device ID and key prefix. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {Entry[]}: the list of all key-value pairs that match the + * specified deviceId and key prefix. + * @returns Returns the list of all key-value pairs meeting the given criteria. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, keyPrefix: string): Promise; + + /** + * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the key-value pairs belong. + * @param {string} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {Entry[]}: the list of all key-value pairs + * matching the specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getEntries(deviceId: string, query: Query, callback: AsyncCallback): void; + + /** + * Obtains the list of key-value pairs matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the key-value pairs belong. + * @param {string} query - Indicates the {@code Query} object. + * @returns {Promise} {Entry[]}: the list of all key-value pairs matching the + * specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100005 - if not support the operation. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + 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 SingleKVStore} + * 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. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback): void; + + /** + * 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 SingleKVStore} + * 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. + * + * @param {string} deviceId - Identifies the device whose data is to be queried. + * @param {string} keyPrefix - Indicates the key prefix to match. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and keyPrefix. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, keyPrefix: string): Promise; + + /** + * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, query: Query, callback: AsyncCallback): void; + + /** + * Obtains the {@code KVStoreResultSet} object matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the {@code KVStoreResultSet} object belongs. + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSet(deviceId: string, query: Query): Promise; + + /** + * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. + * + * @param deviceId Indicates the ID of the device to which the results belong. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @param {AsyncCallback} callback - {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; + + /** + * Obtains the KVStoreResultSet object matching a specified Device ID and Predicate object. + * + * @param deviceId Indicates the ID of the device to which the results belong. + * @param {dataSharePredicates.DataSharePredicates} predicates - Indicates the dataSharePredicates. + * @returns {Promise} {KVStoreResultSet}: the {@code KVStoreResultSet} + * object matching the specified deviceId and {@code dataSharePredicates.DataSharePredicates} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.DataShare.Provider + * @systemapi + * @since 9 + */ + getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + + /** + * Obtains the number of results matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the results belong. + * @param {Query} query - Indicates the {@code Query} object. + * @param {AsyncCallback} callback - {number}: the number of results matching the + * specified deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSize(deviceId: string, query: Query, callback: AsyncCallback): void; + + /** + * Obtains the number of results matching a specified device ID and {@code Query} object. + * + * @param {string} deviceId - Indicates the ID of the device to which the results belong. + * @param {Query} query - Indicates the {@code Query} object. + * @returns {Promise} {number}: the number of results matching the specified + * deviceId and {@code Query} object. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @throws {BusinessError} 15100006 - if the database or result set has been closed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + getResultSize(deviceId: string, query: Query): Promise; + } + + /** + * Creates a {@link KVManager} instance based on the configuration information. + * + *

          You must pass {@link KVManagerConfig} to provide configuration information + * to create a {@link KVManager} instance. + * + * @param {KVManagerConfig} config - Indicates the KVStore configuration information, + * including the package name and context. + * @param {AsyncCallback} callback - {KVManager}: the {@code KVManager} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + function createKVManager(config: KVManagerConfig, callback: AsyncCallback): void; + + /** + * Creates a {@link KVManager} instance based on the configuration information. + * + *

          You must pass {@link KVManagerConfig} to provide configuration information + * to create a {@link KVManager} instance. + * + * @param {KVManagerConfig} config - Indicates the KVStore configuration information, + * including the package name and context. + * @returns {Promise} {KVManager}: the {@code KVManager} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + function createKVManager(config: KVManagerConfig): Promise; + + /** + * Provides interfaces to manage a {@code SingleKVStore} database, including obtaining, closing, and deleting the {@code SingleKVStore}. + * + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + interface KVManager { + /** + * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. + * + * @param {string} storeId - Identifies the KVStore database. The value of this parameter must be unique + * for the same application, and different applications can share the same value. + * @param {Options} options - Indicates the {@code Options} object used for creating and + * obtaining the KVStore database. + * @param {AsyncCallback} callback - {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100002 - if open existed database with changed options. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getKVStore(storeId: string, options: Options, callback: AsyncCallback): void; + + /** + * Creates and obtains a KVStore database by specifying {@code Options} and {@code storeId}. + * + * @param {string} storeId - Identifies the KVStore database. The value of this parameter must be unique + * for the same application, and different applications can share the same value. + * @param {Options} options - Indicates the {@code Options} object used for creating and + * obtaining the KVStore database. + * @returns {Promise} {T}: the {@code SingleKVStore} or {@code DeviceKVStore} instance. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100002 - if open existed database with changed options. + * @throws {BusinessError} 15100003 - if the database is corrupted. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getKVStore(storeId: string, options: Options): Promise; + + /** + * Closes the 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 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 KVStore, otherwise + * closing the database will fail. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to close. + * @param {AsyncCallback} callback - the callback of closeKVStore. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeKVStore(appId: string, storeId: string, callback: AsyncCallback): void; + + /** + * Closes the 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 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 KVStore, otherwise + * closing the database will fail. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to close. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + closeKVStore(appId: string, storeId: string): Promise; + + /** + * Deletes the KVStore database identified by storeId. + * + *

          Before using this method, close all KVStore instances in use that are identified by the same storeId. + * + *

          You can use this method to delete a KVStore database not in use. After the database is deleted, all its data will be + * lost. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to delete. + * @param {AsyncCallback} callback - the callback of deleteKVStore. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100004 - if the database not exist when delete database. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteKVStore(appId: string, storeId: string, callback: AsyncCallback): void; + + /** + * Deletes the KVStore database identified by storeId. + * + *

          Before using this method, close all KVStore instances in use that are identified by the same storeId. + * + *

          You can use this method to delete a KVStore database not in use. After the database is deleted, all its data will be + * lost. + * + * @param {string} appId - Identifies the application that the database belong to. + * @param {string} storeId - Identifies the KVStore database to delete. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if parameter check failed. + * @throws {BusinessError} 15100004 - if the database not exist when delete database. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + deleteKVStore(appId: string, storeId: string): Promise; + + /** + * Obtains the storeId of all KVStore databases that are created by using the {@code getKVStore} method and not deleted by + * calling the {@code deleteKVStore} method. + * + * @param {string} appId - Identifies the application that obtains the databases. + * @param {AsyncCallback} callback - {string[]}: the storeId of all created KVStore databases. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getAllKVStoreId(appId: string, callback: AsyncCallback): void; + + /** + * Obtains the storeId of all KVStore databases that are created by using the {@code getKVStore} method and not deleted by + * calling the {@code deleteKVStore} method. + * + * @param {string} appId - Identifies the application that obtains the databases. + * @returns {Promise} {string[]}: the storeId of all created KVStore databases. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.Core + * @since 9 + */ + getAllKVStoreId(appId: string): Promise; + + /** + * Register a death callback to get notification when service died. + * + * @param {Callback} deathCallback - the service died callback. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @throws {BusinessError} 401 - if parameter check failed. + * @since 9 + */ + on(event: 'distributedDataServiceDie', deathCallback: Callback): void; + + /** + * Unregister the death callback and can not receive service died notification any more. + * + * @param {Callback} deathCallback - the service died callback which has been registered. + * @throws {BusinessError} 401 - if parameter check failed. + * @syscap SystemCapability.DistributedDataManager.KVStore.DistributedKVStore + * @since 9 + */ + off(event: 'distributedDataServiceDie', deathCallback?: Callback): void; + } +} + +export default distributedKVStore; \ No newline at end of file diff --git a/api/@ohos.data.fileAccess.d.ts b/api/@ohos.data.fileAccess.d.ts index 46b8b6c591312332443fbad34b684f7975f8be43..9c31c93412a181b8c3f3fd90f03170827879c594 100644 --- a/api/@ohos.data.fileAccess.d.ts +++ b/api/@ohos.data.fileAccess.d.ts @@ -31,7 +31,7 @@ declare namespace fileAccess { * @syscap SystemCapability.FileManagement.UserFileService * @StageModelOnly * @systemapi - * @permission ohos.permission.FILE_ACCESS_MANAGER + * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @return Returns the wants. */ function getFileAccessAbilityInfo(callback: AsyncCallback>): void; @@ -43,7 +43,7 @@ declare namespace fileAccess { * @syscap SystemCapability.FileManagement.UserFileService * @StageModelOnly * @systemapi - * @permission ohos.permission.FILE_ACCESS_MANAGER + * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @param context Indicates the application context. * @return Returns the fileAccessHelper. */ @@ -55,7 +55,7 @@ declare namespace fileAccess { * @syscap SystemCapability.FileManagement.UserFileService * @StageModelOnly * @systemapi - * @permission ohos.permission.FILE_ACCESS_MANAGER + * @permission ohos.permission.FILE_ACCESS_MANAGER and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @param context Indicates the application context. * @param want Represents the connected data provider. * @return Returns the fileAccessHelper. diff --git a/api/@ohos.data.preferences.d.ts b/api/@ohos.data.preferences.d.ts index 7355e75a0dffcc60643dba1a72af1d1b431e7225..dabe5d7527732f37da97c97481ce853fe7469b76 100644 --- a/api/@ohos.data.preferences.d.ts +++ b/api/@ohos.data.preferences.d.ts @@ -12,8 +12,8 @@ * 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 {AsyncCallback, Callback} from './basic'; +import Context from "./application/BaseContext"; /** * Provides interfaces to obtain and modify preferences data. @@ -30,13 +30,27 @@ declare namespace preferences { *

          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 + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the preferences file name. + * @param {AsyncCallback} callback - the {@link Preferences} instance matching the specified + * preferences file name. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 */ function getPreferences(context: Context, name: string, callback: AsyncCallback): void; + + /** + * 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} context - Indicates the context of application or capability. + * @param {string} name - Indicates the preferences file name. + * @returns {Promise} the {@link Preferences} instance matching the specified preferences file name. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ function getPreferences(context: Context, name: string): Promise; /** @@ -48,12 +62,31 @@ declare namespace preferences { * 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 + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the preferences file name. + * @param {AsyncCallback} callback - Indicates the callback function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 15500010 - if failed to delete preferences file. * @since 9 */ function deletePreferences(context: Context, name: string, callback: AsyncCallback): void; + + /** + * 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} context - Indicates the context of application or capability. + * @param {string} name - Indicates the preferences file name. + * @returns {Promise} a promise object. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 15500010 - if failed to delete preferences file. + * @since 9 + */ function deletePreferences(context: Context, name: string): Promise; /** @@ -64,12 +97,28 @@ declare namespace preferences { * 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 + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the preferences file name. + * @param {AsyncCallback} callback - Indicates the callback function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @since 9 */ function removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback): void; + + /** + * 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} context - Indicates the context of application or capability. + * @param {string} name - Indicates the preferences file name. + * @returns {Promise} a promise object. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ function removePreferencesFromCache(context: Context, name: string): Promise; /** @@ -77,7 +126,7 @@ declare namespace preferences { * *

          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 + * the file that stores preferences data, and use movePreferencesFromCache * to remove the {@link Preferences} instance from the memory. * * @syscap SystemCapability.DistributedDataManager.Preferences.Core @@ -86,39 +135,71 @@ declare namespace preferences { */ 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 - */ + * 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 {string} key - Indicates the key of the preferences. It cannot be {@code null} or empty. + * @param {ValueType} defValue - Indicates the default value to return. + * @param {AsyncCallback} callback - the value matching the specified key if it is found; + * returns the default value otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ get(key: string, defValue: ValueType, callback: AsyncCallback): void; + + /** + * 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 {string} key - Indicates the key of the preferences. It cannot be {@code null} or empty. + * @param {ValueType} defValue - Indicates the default value to return. + * @returns {Promise} the value matching the specified key if it is found; + * returns the default value otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ 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 - */ + * Obtains all the keys and values of a preferences in an object. + * + * @param {AsyncCallback} callback - the values and keys in an object. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ getAll(callback: AsyncCallback): void; + + /** + * Obtains all the keys and values of a preferences in an object. + * + * @returns {Promise} the values and keys in an object. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ 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 + * @param {string} key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * @param {AsyncCallback} callback - {@code true} if the {@link Preferences} object contains a preferences + * with the specified key;returns {@code false} otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @since 9 */ has(key: string, callback: AsyncCallback): void; + + /** + * Checks whether the {@link Preferences} object contains a preferences matching a specified key. + * + * @param {string} key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * @returns {Promise} {@code true} if the {@link Preferences} object contains + * a preferences with the specified key; returns {@code false} otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ has(key: string): Promise; /** @@ -127,13 +208,28 @@ declare namespace preferences { *

          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 + * @param {string} key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * @param {ValueType} value - Indicates the value of the preferences. + * MAX_KEY_LENGTH. + * @param {AsyncCallback} callback - Indicates the callback function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @since 9 */ put(key: string, value: ValueType, callback: AsyncCallback): void; + + /** + * 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 {string} key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * @param {ValueType} value - Indicates the value of the preferences. + * MAX_KEY_LENGTH. + * @returns {Promise} a promise object. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ put(key: string, value: ValueType): Promise; /** @@ -142,40 +238,70 @@ declare namespace preferences { *

          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 + * @param {string} key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param {AsyncCallback} callback - Indicates the callback function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @since 9 */ delete(key: string, callback: AsyncCallback): void; - delete(key: string): Promise; /** - * Clears all preferences from the {@link Preferences} object. + * 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. * - * @throws BusinessError if invoked failed + * @param {string} key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @returns {Promise} a promise object. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @since 9 + */ + 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. + * + * @param {AsyncCallback} callback - Indicates the callback function. * @since 9 */ clear(callback: AsyncCallback): void; + + /** + * Clears all preferences from the {@link Preferences} object. + * + *

          You can call the {@link #flush} method to save the {@link Preferences} object to the file. + * + * @returns {Promise} a promise object. + * @since 9 + */ clear(): Promise; /** * Asynchronously saves the {@link Preferences} object to the file. * - * @throws BusinessError if invoked failed + * @param {AsyncCallback} callback - Indicates the callback function. * @since 9 */ flush(callback: AsyncCallback): void; + + /** + * Asynchronously saves the {@link Preferences} object to the file. + * + * @returns {Promise} a promise object. + * @since 9 + */ 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 + * @param {Callback} callback - indicates the callback when preferences changes. + * @param {Callback<{key: string}>} callback - Indicates the callback function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @since 9 */ on(type: 'change', callback: Callback<{ key: string }>): void; @@ -183,8 +309,9 @@ declare namespace preferences { /** * Unregisters an existing observer. * - * @param callback Indicates the registered callback. - * @throws BusinessError if invoked failed + * @param {Callback} callback - indicates the callback when preferences changes. + * @param {Callback<{key: string}>} callback - Indicates the callback function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @since 9 */ off(type: 'change', callback?: Callback<{ key: string }>): void; diff --git a/api/@ohos.data.rdb.d.ts b/api/@ohos.data.rdb.d.ts index 9ae430851bb9a4c578c907474d72fbfaec73dec4..28762906aaf6a8e242af278da0a8eb9413f173c8 100644 --- a/api/@ohos.data.rdb.d.ts +++ b/api/@ohos.data.rdb.d.ts @@ -13,48 +13,142 @@ * limitations under the License. */ -import {AsyncCallback, Callback} from './basic'; -import { ResultSet as _ResultSet } from './data/rdb/resultSet'; +import{ AsyncCallback, Callback } from './basic'; +import{ ResultSet as _ResultSet } from './data/rdb/resultSet'; +import{ ResultSetV9 as _ResultSetV9 } 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'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 */ -declare namespace 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 + * @param {Context} context - Indicates the context of application or capability. + * @param {StoreConfig} config - Indicates the {@link StoreConfig} configuration of the database related to this RDB store. + * @param {number} version - Indicates the database version for upgrade or downgrade. + * @param {AsyncCallback} callback - the RDB store {@link RdbStore}. * @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}. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.getRdbStoreV9 */ function getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback): void; + + /** + * 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. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {StoreConfig} config - Indicates the {@link StoreConfig} configuration of the database related to this RDB store. + * @param {number} version - Indicates the database version for upgrade or downgrade. + * @returns {Promise} the RDB store {@link RdbStore}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.getRdbStoreV9 + */ function getRdbStore(context: Context, config: StoreConfig, version: number): Promise; + /** + * 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. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {StoreConfigV9} config - Indicates the {@link StoreConfigV9} configuration of the database related to this RDB store. + * @param {number} version - Indicates the database version for upgrade or downgrade. + * @param {AsyncCallback} callback - the RDB store {@link RdbStoreV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed open database by invalid database name + * @throws {BusinessError} 14800011 - if failed open database by database corrupted + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number, callback: AsyncCallback): void; + + /** + * 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. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {StoreConfigV9} config - Indicates the {@link StoreConfigV9} configuration of the database related to this RDB store. + * @param {number} version - Indicates the database version for upgrade or downgrade. + * @returns {Promise} the RDB store {@link RdbStoreV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed open database by invalid database name + * @throws {BusinessError} 14800011 - if failed open database by database corrupted + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function getRdbStoreV9(context: Context, config: StoreConfigV9, version: number): Promise; + /** * Deletes the database with a specified name. * - * @since 7 + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the database name. + * @param {AsyncCallback} callback - the callback of deleteRdbStore. * @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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.deleteRdbStoreV9 */ function deleteRdbStore(context: Context, name: string, callback: AsyncCallback): void; + /** + * Deletes the database with a specified name. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the database name. + * @returns {Promise} the promise returned by the function. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.deleteRdbStoreV9 + */ function deleteRdbStore(context: Context, name: string): Promise; + /** + * Deletes the database with a specified name. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the database name. + * @param {AsyncCallback} callback - the callback of deleteRdbStore. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed delete database by invalid database name + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function deleteRdbStoreV9(context: Context, name: string, callback: AsyncCallback): void; + + /** + * Deletes the database with a specified name. + * + * @param {Context} context - Indicates the context of application or capability. + * @param {string} name - Indicates the database name. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @throws {BusinessError} 14800010 - if failed delete database by invalid database name + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + function deleteRdbStoreV9(context: Context, name: string): Promise; + /** * Indicates the database synchronization mode. * @@ -95,661 +189,1711 @@ declare namespace rdb { SUBSCRIBE_TYPE_REMOTE = 0, } + /** + * Describes the {@code RdbStoreV9} type. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + enum SecurityLevel { + /** + * S1: mains the db is low level security + * There are some low impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S1 = 1, + + /** + * S2: mains the db is middle level security + * There are some major impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S2 = 2, + + /** + * S3: mains the db is high level security + * There are some severity impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S3 = 3, + + /** + * S4: mains the db is critical level security + * There are some critical impact, when the data is leaked. + * + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + S4 = 4, + } + /** * 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'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9 */ interface RdbStore { /** * Inserts a row of data into the target table. * - * @since 7 + * @param {string} table - Indicates the row of data to be inserted into the table. + * @param {ValuesBucket} values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. + * @param {AsyncCallback} callback - the row ID if the operation is successful. returns -1 otherwise. * @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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.insert */ insert(table: string, values: ValuesBucket, callback: AsyncCallback): void; + + /** + * Inserts a row of data into the target table. + * + * @param {string} table - Indicates the row of data to be inserted into the table. + * @param {ValuesBucket} values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. + * @returns {Promise} return the row ID if the operation is successful. return -1 otherwise. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.insert + */ insert(table: string, values: ValuesBucket): Promise; /** * Inserts a batch of data into the target table. * - * @since 9 + * @param {string} table - Indicates the target table. + * @param {Array} values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. + * @param {AsyncCallback} callback - the number of values that were inserted if the operation is successful. returns -1 otherwise. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param table Indicates the target table. - * @param values Indicates the rows of data to be inserted into the table. - * @return Returns the number of values that were inserted if the operation is successful; returns -1 otherwise. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.batchInsert */ batchInsert(table: string, values: Array, callback: AsyncCallback): void; - batchInsert(table: string, values: Array): Promise; /** - * Updates data in the database based on a a specified instance object of rdbPredicates. + * Inserts a batch of data into the target table. * + * @param {string} table - Indicates the target table. + * @param {Array} values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. + * @returns {Promise} return the number of values that were inserted if the operation is successful. returns -1 otherwise. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.batchInsert + */ + batchInsert(table: string, values: Array): Promise; + + /** + * Updates data in the database based on a a specified instance object of RdbPredicates. + * + * @param {ValuesBucket} values - Indicates 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 {RdbPredicates} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicates}. + * @param {AsyncCallback} callback - the number of affected rows. * @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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.update */ 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. + * Updates data in the database based on a a specified instance object of RdbPredicates. * - * @since 9 + * @param {ValuesBucket} values - Indicates 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 {RdbPredicates} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicates}. + * @returns {Promise} return the number of affected rows. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @systemapi - * @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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.update */ - update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; - update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise; - + update(values: ValuesBucket, predicates: RdbPredicates): Promise; + /** - * Deletes data from the database based on a specified instance object of rdbPredicates. + * Deletes data from the database based on a specified instance object of RdbPredicates. * - * @since 7 + * @param {RdbPredicates} predicates - the specified delete condition by the instance object of {@link RdbPredicates}. + * @param {AsyncCallback} callback - the number of affected rows. * @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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.delete */ delete(predicates: RdbPredicates, callback: AsyncCallback): void; - delete(predicates: RdbPredicates): Promise; /** - * Deletes data from the database based on a specified instance object of DataSharePredicates. + * Deletes data from the database based on a specified instance object of RdbPredicates. * - * @since 9 + * @param {RdbPredicates} predicates - the specified delete condition by the instance object of {@link RdbPredicates}. + * @returns {Promise} return the number of affected rows. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @systemapi - * @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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.delete */ - delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; - delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise; + delete(predicates: RdbPredicates): Promise; /** * Queries data in the database based on specified conditions. * - * @since 7 + * @param {RdbPredicates} predicates - the specified query condition by the instance object of {@link RdbPredicates}. + * @param {Array} columns - the columns to query. If the value is empty array, the query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSet} object if the operation is successful. * @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; + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.query */ 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 + * @param {RdbPredicates} predicates - the specified query condition by the instance object of {@link RdbPredicates}. + * @param {Array} columns - the columns to query. If the value is null, the query applies to all columns. + * @returns {Promise} return the {@link ResultSet} object if the operation is successful. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @systemapi - * @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; + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.query */ - query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, callback: AsyncCallback): void; - query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array): Promise; - - /** - * Queries remote data in the database based on specified conditions before Synchronizing Data. + query(predicates: RdbPredicates, columns ?: Array): Promise; + + /** + * Deletes data from the database based on a specified instance object of RdbPredicates. * - * @since 9 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} return the {@link ResultSet} object if the operation is successful. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param device Indicates specified remote device. - * @param table Indicates the target table. - * @param predicates Indicates the specified remote query condition by the instance object of RdbPredicates. - * @param columns Indicates the columns to remote query. If the value is null, the remote query applies to all columns. - * @return Returns a ResultSet object if the operation is successful; + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.querySql */ - remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array, callback: AsyncCallback): void; - remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array): Promise; - + querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void; /** - * Queries data in the database based on SQL statement. + * Deletes data from the database based on a specified instance object of RdbPredicates. * - * @since 8 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} return the {@link ResultSet} object if the operation is successful. * @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; + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.querySql */ - querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void; - querySql(sql: string, bindArgs?: Array): Promise; + querySql(sql: string, bindArgs ?: Array): Promise; /** * Executes an SQL statement that contains specified parameters but returns no value. * - * @since 7 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @param {AsyncCallback} callback - the callback of executeSql. * @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. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.executeSql */ executeSql(sql: string, bindArgs: Array, callback: AsyncCallback): void; - executeSql(sql: string, bindArgs?: Array): Promise; /** - * beginTransaction before excute your sql + * Executes an SQL statement that contains specified parameters but returns no value. * - * @since 8 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} the promise returned by the function. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.executeSql */ - beginTransaction():void; + executeSql(sql: string, bindArgs ?: Array): Promise; /** - * commit the the sql you have excuted. + * Begin Transaction before excute your sql. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.beginTransaction */ - commit():void; + beginTransaction(): void; /** - * roll back the sql you have already excuted + * Commit the the sql you have excuted. * - * @since 8 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.commit */ - rollBack():void; + commit(): void; /** - * Backs up a database in a specified name. + * Roll back the sql you have already excuted. * - * @since 9 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param destName Indicates the name that saves the database backup. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.rollBack */ - backup(destName:string, callback: AsyncCallback):void; - backup(destName:string): Promise; + rollBack(): void; /** - * Restores a database from a specified database file. + * Set table to be distributed table. * - * @since 9 + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {Array} tables - Indicates the tables name you want to set. + * @param {AsyncCallback} callback - the callback of setDistributedTables. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param srcName Indicates the name that saves the database file. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.setDistributedTables */ - restore(srcName:string, callback: AsyncCallback):void; - restore(srcName:string): Promise; + setDistributedTables(tables: Array, callback: AsyncCallback): void; /** * 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 + * @param {Array} tables - Indicates the tables name you want to set. + * @returns {Promise} the promise returned by the function. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.setDistributedTables */ - 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. + * @param {string} device - Indicates the remote device. + * @param {AsyncCallback} callback - {string}: the distributed table name. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.obtainDistributedTableName */ obtainDistributedTableName(device: string, table: string, callback: AsyncCallback): void; - obtainDistributedTableName(device: string, table: string): Promise; /** - * Sync data between devices + * 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 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 + * @param {string} device - Indicates the remote device. + * @returns {Promise} {string}: the distributed table name. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.obtainDistributedTableName */ - sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback>): void; - sync(mode: SyncMode, predicates: RdbPredicates): Promise>; + obtainDistributedTableName(device: string, table: string): Promise; /** - * Registers an observer for the database. When data in the distributed database changes, - * the callback will be invoked. + * Sync data between devices. * - * @since 8 + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @param {AsyncCallback>} callback - {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status. * @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. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.sync + */ + sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback>): void; + + /** + * Sync data between devices. + * * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @returns {Promise>} {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.sync */ + sync(mode: SyncMode, predicates: RdbPredicates): Promise>; + + /** + * Registers an observer for the database. When data in the distributed database changes, + * the callback will be invoked. + * + * @param {string} event - Indicates the event must be string 'dataChange'. + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@link SubscribeType}. + * @param {AsyncCallback>} observer - {Array}: the observer of data change events in the distributed database. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.on + */ on(event: 'dataChange', type: SubscribeType, observer: Callback>): void; /** * Remove specified observer of specified type from the database. * - * @since 8 + * @param {string} event - Indicates the event must be string 'dataChange'. + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@link SubscribeType}. + * @param {AsyncCallback>} observer - {Array}: the data change observer already registered. * @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 + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbStoreV9.off */ - off(event:'dataChange', type: SubscribeType, observer: Callback>): void; + off(event: 'dataChange', type: SubscribeType, observer: Callback>): void; } /** - * Indicates possible value types + * Provides methods for managing the relational database (RDB). * - * @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 + * 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'; - */ - 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'; + * @since 9 */ - interface StoreConfig { - name: string; - + interface RdbStoreV9 { /** - * Specifies whether the database is encrypted. + * Inserts a row of data into the target table. * - * @since 9 + * @param {string} table - Indicates the row of data to be inserted into the table. + * @param {ValuesBucket} values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. + * @param {AsyncCallback} callback - the row ID if the operation is successful. returns -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @import import data_rdb from '@ohos.data.rdb'; - */ - encrypt?: boolean; - } + * @since 9 + */ + insert(table: string, values: ValuesBucket, callback: AsyncCallback): void; - /** - * 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. + * Inserts a row of data into the target table. * - * @since 7 + * @param {string} table - Indicates the row of data to be inserted into the table. + * @param {ValuesBucket} values - Indicates the row of data {@link ValuesBucket} to be inserted into the table. + * @returns {Promise} return the row ID if the operation is successful. return -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 */ - constructor(name: string) + insert(table: string, values: ValuesBucket): Promise; /** - * Specify remote devices when syncing distributed database. + * Inserts a batch of data into the target table. * - * @note When query database, this function should not be called. - * @since 8 + * @param {string} table - Indicates the target table. + * @param {Array} values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. + * @param {AsyncCallback} callback - the number of values that were inserted if the operation is successful. returns -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param devices Indicates specified remote devices. - * @return Returns the RdbPredicates self. + * @since 9 */ - inDevices(devices: Array): RdbPredicates; + batchInsert(table: string, values: Array, callback: AsyncCallback): void; /** - * Specify all remote devices which connect to local device when syncing distributed database. + * Inserts a batch of data into the target table. * - * @note When query database, this function should not be called. - * @since 8 + * @param {string} table - Indicates the target table. + * @param {Array} values - Indicates the rows of data {@link ValuesBucket} to be inserted into the table. + * @returns {Promise} return the number of values that were inserted if the operation is successful. returns -1 otherwise. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns the RdbPredicates self. + * @since 9 */ - inAllDevices(): RdbPredicates; + batchInsert(table: string, values: Array): Promise; /** - * Configures the RdbPredicates to match the field whose data type is ValueType and value is equal - * to a specified value. + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. * - * @note This method is similar to = of the SQL statement. - * @since 7 + * @param {ValuesBucket} values - Indicates 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 {RdbPredicatesV9} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicatesV9}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - equalTo(field: string, value: ValueType): RdbPredicates; + update(values: ValuesBucket, predicates: RdbPredicatesV9, callback: AsyncCallback): void; /** - * Configures the RdbPredicates to match the field whose data type is ValueType and value is unequal to - * a specified value. + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. * - * @note This method is similar to != of the SQL statement. - * @since 7 + * @param {ValuesBucket} values - Indicates 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 {RdbPredicatesV9} predicates - Indicates the specified update condition by the instance object of {@link RdbPredicatesV9}. + * @returns {Promise} return the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - notEqualTo(field: string, value: ValueType): RdbPredicates; + update(values: ValuesBucket, predicates: RdbPredicatesV9): Promise; /** - * Adds a left parenthesis to the RdbPredicates. + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. * - * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap(). - * @since 7 + * @param {string} table - Indicates the target table. + * @param {ValuesBucket} 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 {DataSharePredicates} predicates - Indicates the specified update condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns the RdbPredicates with the left parenthesis. + * @since 9 */ - beginWrap(): RdbPredicates; + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; /** - * Adds a right parenthesis to the RdbPredicates. + * Updates data in the database based on a a specified instance object of RdbPredicatesV9. * - * @note This method is similar to ) of the SQL statement and needs to be used together - * with beginWrap(). - * @since 7 + * @param {string} table - Indicates the target table. + * @param {ValuesBucket} 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 {DataSharePredicates} predicates - Indicates the specified update condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @returns {Promise} return the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns the RdbPredicates with the right parenthesis. + * @since 9 */ - endWrap(): RdbPredicates; + update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates): Promise; /** - * Adds an or condition to the RdbPredicates. + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. * - * @note This method is similar to or of the SQL statement. - * @since 7 + * @param {RdbPredicatesV9} predicates - the specified delete condition by the instance object of {@link RdbPredicatesV9}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns the RdbPredicates with the or condition. + * @since 9 */ - or(): RdbPredicates; + delete(predicates: RdbPredicatesV9, callback: AsyncCallback): void; /** - * Adds an and condition to the RdbPredicates. + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. * - * @note This method is similar to and of the SQL statement. - * @since 7 + * @param {RdbPredicatesV9} predicates - the specified delete condition by the instance object of {@link RdbPredicatesV9}. + * @returns {Promise} return the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns the RdbPredicates with the and condition. + * @since 9 */ - and(): RdbPredicates; + delete(predicates: RdbPredicatesV9): Promise; /** - * Configures the RdbPredicates to match the field whose data type is string and value - * contains a specified value. + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. * - * @note This method is similar to contains of the SQL statement. - * @since 7 + * @param {string} table - Indicates the target table. + * @param {DataSharePredicates} predicates - the specified delete condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - contains(field: string, value: string): RdbPredicates; + delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback): void; /** - * Configures the RdbPredicates to match the field whose data type is string and value starts - * with a specified string. + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. * - * @note This method is similar to value% of the SQL statement. - * @since 7 + * @param {string} table - Indicates the target table. + * @param {DataSharePredicates} predicates - the specified delete condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {AsyncCallback} callback - the number of affected rows. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - beginsWith(field: string, value: string): RdbPredicates; + delete(table: string, predicates: dataSharePredicates.DataSharePredicates): Promise; /** - * Configures the RdbPredicates to match the field whose data type is string and value - * ends with a specified string. + * Queries data in the database based on specified conditions. * - * @note This method is similar to %value of the SQL statement. - * @since 7 + * @param {RdbPredicatesV9} predicates - the specified query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to query. If the value is empty array, the query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - endsWith(field: string, value: string): RdbPredicates; + query(predicates: RdbPredicatesV9, columns: Array, callback: AsyncCallback): void; /** - * Configures the RdbPredicates to match the fields whose value is null. + * Queries data in the database based on specified conditions. * - * @note This method is similar to is null of the SQL statement. - * @since 7 + * @param {RdbPredicatesV9} predicates - the specified query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to query. If the value is null, the query applies to all columns. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param field Indicates the column name in the database table. - * @return Returns the RdbPredicates that match the specified field. + * @since 9 */ - isNull(field: string): RdbPredicates; + query(predicates: RdbPredicatesV9, columns ?: Array): Promise; /** - * Configures the RdbPredicates to match the specified fields whose value is not null. + * Queries data in the database based on specified conditions. * - * @note This method is similar to is not null of the SQL statement. - * @since 7 + * @param {string} table - Indicates the target table. + * @param {dataSharePredicates.DataSharePredicates} predicates - the specified query condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {Array} columns - the columns to query. If the value is empty array, the query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param field Indicates the column name in the database table. - * @return Returns the RdbPredicates that match the specified field. + * @since 9 */ - isNotNull(field: string): RdbPredicates; + query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array, callback: AsyncCallback): void; /** - * Configures the RdbPredicates to match the fields whose data type is string and value is - * similar to a specified string. + * Queries data in the database based on specified conditions. * - * @note This method is similar to like of the SQL statement. - * @since 7 + * @param {string} table - Indicates the target table. + * @param {dataSharePredicates.DataSharePredicates} predicates - the specified query condition by the instance object of {@link dataSharePredicates.DataSharePredicates}. + * @param {Array} columns - the columns to query. If the value is null, the query applies to all columns. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - like(field: string, value: string): RdbPredicates; + query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns ?: Array): Promise; /** - * Configures RdbPredicates to match the specified field whose data type is string and the value contains - * a wildcard. + * Queries remote data in the database based on specified conditions before Synchronizing Data. * - * @note Different from like, the input parameters of this method are case-sensitive. - * @since 7 + * @param {string} device - Indicates specified remote device. + * @param {string} table - Indicates the target table. + * @param {RdbPredicatesV9} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to remote query. If the value is empty array, the remote query applies to all columns. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - glob(field: string, value: string): RdbPredicates; + remoteQuery(device: string, table: string, predicates: RdbPredicatesV9, columns: Array, callback: AsyncCallback): void; /** - * Restricts the value of the field to the range between low value and high value. + * Queries remote data in the database based on specified conditions before Synchronizing Data. * - * @since 7 + * @param {string} device - Indicates specified remote device. + * @param {string} table - Indicates the target table. + * @param {RdbPredicatesV9} predicates - the specified remote remote query condition by the instance object of {@link RdbPredicatesV9}. + * @param {Array} columns - the columns to remote query. If the value is empty array, the remote query applies to all columns. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - between(field: string, low: ValueType, high: ValueType): RdbPredicates; + remoteQuery(device: string, table: string, predicates: RdbPredicatesV9, columns: Array): Promise; /** - * Configures RdbPredicates to match the specified field whose data type is int and value is - * out of a given range. + * Queries data in the database based on SQL statement. * - * @since 7 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @param {AsyncCallback} callback - the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; + querySql(sql: string, bindArgs: Array, callback: AsyncCallback): void; /** - * Restricts the value of the field to be greater than the specified value. + * Deletes data from the database based on a specified instance object of RdbPredicatesV9. * - * @since 7 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} return the {@link ResultSetV9} object if the operation is successful. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - greaterThan(field: string, value: ValueType): RdbPredicates; + querySql(sql: string, bindArgs ?: Array): Promise; /** - * Restricts the value of the field to be smaller than the specified value. + * Executes an SQL statement that contains specified parameters but returns no value. * - * @since 7 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @param {AsyncCallback} callback - the callback of executeSql. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - lessThan(field: string, value: ValueType): RdbPredicates; + executeSql(sql: string, bindArgs: Array, callback: AsyncCallback): void; /** - * Restricts the value of the field to be greater than or equal to the specified value. + * Executes an SQL statement that contains specified parameters but returns no value. * - * @since 7 + * @param {string} sql - Indicates the SQL statement to execute. + * @param {Array} bindArgs - Indicates the {@link ValueType} values of the parameters in the SQL statement. The values are strings. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + executeSql(sql: string, bindArgs ?: Array): Promise; /** - * Restricts the value of the field to be smaller than or equal to the specified value. + * BeginTransaction before excute your sql. * - * @since 7 + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + beginTransaction(): void; /** - * Restricts the ascending order of the return list. When there are several orders, - * the one close to the head has the highest priority. + * Commit the the sql you have executed. * - * @since 7 + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - orderByAsc(field: string): RdbPredicates; + commit(): void; /** - * Restricts the descending order of the return list. When there are several orders, - * the one close to the head has the highest priority. + * Roll back the sql you have already executed. * - * @since 7 + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - orderByDesc(field: string): RdbPredicates; + rollBack(): void; /** - * Restricts each row of the query result to be unique. + * Backs up a database in a specified name. * - * @since 7 + * @param {string} destName - Indicates the name that saves the database backup. + * @param {AsyncCallback} callback - the callback of backup. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns the SQL query statement with the specified RdbPredicates. + * @since 9 */ - distinct(): RdbPredicates; + backup(destName: string, callback: AsyncCallback): void; /** - * Restricts the max number of return records. + * Backs up a database in a specified name. * - * @since 7 + * @param {string} destName - Indicates the name that saves the database backup. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - limitAs(value: number): RdbPredicates; + backup(destName: string): Promise; /** - * Configures RdbPredicates to specify the start position of the returned result. + * Restores a database from a specified database file. * - * @note Use this method together with limit(int). - * @since 7 + * @param {string} srcName - Indicates the name that saves the database file. + * @param {AsyncCallback} callback - the callback of restore. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - offsetAs(rowOffset: number): RdbPredicates; + restore(srcName: string, callback: AsyncCallback): void; /** - * Configures RdbPredicates to group query results by specified columns. + * Restores a database from a specified database file. * - * @since 7 + * @param {string} srcName - Indicates the name that saves the database file. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - groupBy(fields: Array): RdbPredicates; + restore(srcName: string): Promise; /** - * Configures RdbPredicates to specify the index column. + * Set table to be distributed table. * - * @note Before using this method, you need to create an index column. - * @since 7 + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {Array} tables - Indicates the tables name you want to set. + * @param {AsyncCallback} callback - the callback of setDistributedTables. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param indexName Indicates the name of the index column. - * @return Returns RdbPredicates with the specified index column. + * @since 9 */ - indexedBy(field: string): RdbPredicates; + setDistributedTables(tables: Array, callback: AsyncCallback): void; /** - * Configures RdbPredicates to match the specified field whose data type is ValueType array and values - * are within a given range. + * Set table to be distributed table. * - * @since 7 + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {Array} tables - Indicates the tables name you want to set. + * @returns {Promise} the promise returned by the function. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - in(field: string, value: Array): RdbPredicates; + setDistributedTables(tables: Array): Promise; /** - * Configures RdbPredicates to match the specified field whose data type is ValueType array and values - * are out of a given range. + * Obtain distributed table name of specified remote device according to local table name. + * When query remote device database, distributed table name is needed. * - * @since 7 + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @param {AsyncCallback} callback - {string}: the distributed table name. + * @throws {BusinessError} 401 - if the parameter type is incorrect. * @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. + * @since 9 */ - notIn(field: string, value: Array): RdbPredicates; + obtainDistributedTableName(device: string, table: string, callback: AsyncCallback): void; + + /** + * Obtain distributed table name of specified remote device according to local table name. + * When query remote device database, distributed table name is needed. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @returns {Promise} {string}: the distributed table name. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + obtainDistributedTableName(device: string, table: string): Promise; + + /** + * Sync data between devices. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @param {AsyncCallback>} callback - {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + sync(mode: SyncMode, predicates: RdbPredicatesV9, callback: AsyncCallback>): void; + + /** + * Sync data between devices. + * + * @permission ohos.permission.DISTRIBUTED_DATASYNC + * @param {string} device - Indicates the remote device. + * @returns {Promise>} {Array<[string, number]>}: devices sync status array, {string}: device id, {number}: device sync status. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + sync(mode: SyncMode, predicates: RdbPredicatesV9): Promise>; + + /** + * Registers an observer for the database. When data in the distributed database changes, + * the callback will be invoked. + * + * @param {string} event - Indicates the event must be string 'dataChange'. + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@link SubscribeType}. + * @param {AsyncCallback>} observer - {Array}: the observer of data change events in the distributed database. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + on(event: 'dataChange', type: SubscribeType, observer: Callback>): void; + + /** + * Remove specified observer of specified type from the database. + * + * @param {string} event - Indicates the event must be string 'dataChange'. + * @param {SubscribeType} type - Indicates the subscription type, which is defined in {@link SubscribeType}. + * @param {AsyncCallback>} observer - {Array}: the data change observer already registered. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + off(event: 'dataChange', type: SubscribeType, observer: Callback>): void; } - export type ResultSet = _ResultSet + /** + * Indicates possible value types + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + */ + type ValueType = number | string | boolean; + + /** + * Values in buckets are stored in key-value pairs + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + */ + type ValuesBucket = { [key:string]: ValueType | Uint8Array | null; +} + +/** + * Manages relational database configurations. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.StoreConfigV9 + */ +interface StoreConfig { + name: string; +} + +/** + * Manages relational database configurations. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ +interface StoreConfigV9 { + /** + * The database name. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + name: string; + + /** + * Specifies whether the database is encrypted. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + securityLevel: SecurityLevel; + + /** + * Specifies whether the database is encrypted. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + encrypt ?: boolean; +} + +/** + * Manages relational database configurations. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9 + */ +class RdbPredicates { + /** + * A parameterized constructor used to create an RdbPredicates instance. + * + * @param {string} name - Indicates the table name of the database. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.constructor + */ + constructor(name: string) + + /** + * Sync data between devices. + * + * @note When query database, this function should not be called. + * @param {Array} devices - Indicates specified remote devices. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.inDevices + */ + 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. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 8 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.inAllDevices + */ + inAllDevices(): RdbPredicates; + + /** + * Configures the RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.equalTo + */ + equalTo(field: string, value: ValueType): RdbPredicates; + + /** + * Configures the RdbPredicatesV9 to match the field whose data type is ValueType and value is not equal to + * a specified value. + * + * @note This method is similar to != of the SQL statement. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.notEqualTo + */ + 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(). + * @returns {RdbPredicates} - the {@link RdbPredicates} with the left parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.beginWrap + */ + 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(). + * @returns {RdbPredicates} - the {@link RdbPredicates} with the right parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.endWrap + */ + endWrap(): RdbPredicates; + + /** + * Adds an or condition to the RdbPredicates. + * + * @note This method is similar to or of the SQL statement. + * @return Returns the {@link RdbPredicates} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.or + */ + or(): RdbPredicates; + + /** + * Adds an and condition to the RdbPredicates. + * + * @note This method is similar to or of the SQL statement. + * @return Returns the {@link RdbPredicates} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.and + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.contains + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.beginsWith + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.endsWith + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.isNull + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @returns {RdbPredicates} - the {@link RdbPredicates} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.isNotNull + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the {@link RdbPredicates} that match the specified field. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.like + */ + 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.glob + */ + glob(field: string, value: string): RdbPredicates; + + /** + * Configures RdbPredicates to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @param {string} field - Indicates the column name. + * @param {ValueType} low - Indicates the minimum value. + * @param {ValueType} high - Indicates the maximum value. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.between + */ + 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. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} low - Indicates the minimum value. + * @param {ValueType} high - Indicates the maximum value to. + * @returns {RdbPredicates} - the SQL statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.notBetween + */ + notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be greater than the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.greaterThan + */ + greaterThan(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.lessThan + */ + lessThan(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.greaterThanOrEqualTo + */ + greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates; + + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicates}. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.lessThanOrEqualTo + */ + 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. + * + * @param {string} field - Indicates the column name for sorting the return list. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.orderByAsc + */ + 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. + * + * @param {string} field - Indicates the column name for sorting the return list. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.orderByDesc + */ + orderByDesc(field: string): RdbPredicates; + + /** + * Restricts each row of the query result to be unique. + * + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.distinct + */ + distinct(): RdbPredicates; + + /** + * Restricts the max number of return records. + * + * @param {number} value - Indicates the max length of the return list. + * @returns {RdbPredicates} - the SQL query statement with the specified {@link RdbPredicates}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.limitAs + */ + limitAs(value: number): RdbPredicates; + + /** + * Configures RdbPredicatesV9 to specify the start position of the returned result. + * + * @note Use this method together with limit(int). + * @param {number} rowOffset - Indicates the start position of the returned result. The value is a positive integer. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.offsetAs + */ + offsetAs(rowOffset: number): RdbPredicates; + + /** + * Configures RdbPredicatesV9 to group query results by specified columns. + * + * @param {Array} fields - Indicates the specified columns by which query results are grouped. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.groupBy + */ + groupBy(fields: Array): RdbPredicates; + + /** + * Configures RdbPredicatesV9 to specify the index column. + * + * @note Before using this method, you need to create an index column. + * @param {string} field - Indicates the name of the index column. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.indexedBy + */ + indexedBy(field: string): RdbPredicates; + + /** + * Configures RdbPredicatesV9 to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.in + */ + in(field: string, value: Array): RdbPredicates; + + /** + * Configures RdbPredicatesV9 to match the specified field whose data type is ValueType array and values + * are out of a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.RdbPredicatesV9.notIn + */ + notIn(field: string, value: Array): RdbPredicates; +} + +/** + * Manages relational database configurations. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ +class RdbPredicatesV9 { + /** + * A parameterized constructor used to create an RdbPredicates instance. + * + * @param {string} name - Indicates the table name of the database. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + constructor(name: string) + + /** + * Sync data between devices. + * + * @note When query database, this function should not be called. + * @param {Array} devices - Indicates specified remote devices. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + inDevices(devices: Array): RdbPredicatesV9; + + /** + * Specify all remote devices which connect to local device when syncing distributed database. + * + * @note When query database, this function should not be called. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + inAllDevices(): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + equalTo(field: string, value: ValueType): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 to match the field whose data type is ValueType and value is not equal to + * a specified value. + * + * @note This method is similar to != of the SQL statement. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + notEqualTo(field: string, value: ValueType): RdbPredicatesV9; + + /** + * Adds a left parenthesis to the RdbPredicatesV9. + * + * @note This method is similar to ( of the SQL statement and needs to be used together with endWrap(). + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} with the left parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + beginWrap(): RdbPredicatesV9; + + /** + * Adds a right parenthesis to the RdbPredicatesV9. + * + * @note This method is similar to ) of the SQL statement and needs to be used together + * with beginWrap(). + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} with the right parenthesis. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + endWrap(): RdbPredicatesV9; + + /** + * Adds an or condition to the RdbPredicatesV9. + * + * @note This method is similar to or of the SQL statement. + * @return Returns the {@link RdbPredicatesV9} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + or(): RdbPredicatesV9; + + /** + * Adds an and condition to the RdbPredicatesV9. + * + * @note This method is similar to or of the SQL statement. + * @return Returns the {@link RdbPredicatesV9} with the or condition. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + and(): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + contains(field: string, value: string): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + beginsWith(field: string, value: string): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + endsWith(field: string, value: string): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 to match the fields whose value is null. + * + * @note This method is similar to is null of the SQL statement. + * @param {string} field - Indicates the column name in the database table. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isNull(field: string): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 to match the specified fields whose value is not null. + * + * @note This method is similar to is not null of the SQL statement. + * @param {string} field - Indicates the column name in the database table. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} self. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isNotNull(field: string): RdbPredicatesV9; + + /** + * Configures the RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the {@link RdbPredicatesV9} that match the specified field. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + like(field: string, value: string): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 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. + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + glob(field: string, value: string): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to match the specified field whose data type is string and the value contains + * a wildcard. + * + * @param {string} field - Indicates the column name. + * @param {ValueType} low - Indicates the minimum value. + * @param {ValueType} high - Indicates the maximum value. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + between(field: string, low: ValueType, high: ValueType): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to match the specified field whose data type is int and value is + * out of a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} low - Indicates the minimum value. + * @param {ValueType} high - Indicates the maximum value to. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + notBetween(field: string, low: ValueType, high: ValueType): RdbPredicatesV9; + + /** + * Restricts the value of the field to be greater than the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + greaterThan(field: string, value: ValueType): RdbPredicatesV9; + + /** + * Restricts the value of the field to be smaller than the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + lessThan(field: string, value: ValueType): RdbPredicatesV9; + + /** + * Restricts the value of the field to be greater than or equal to the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicatesV9; + + /** + * Restricts the value of the field to be smaller than or equal to the specified value. + * + * @param {string} field - Indicates the column name in the database table. + * @param {ValueType} value - Indicates the value to match with the {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + lessThanOrEqualTo(field: string, value: ValueType): RdbPredicatesV9; + + /** + * Restricts the ascending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @param {string} field - Indicates the column name for sorting the return list. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + orderByAsc(field: string): RdbPredicatesV9; + + /** + * Restricts the descending order of the return list. When there are several orders, + * the one close to the head has the highest priority. + * + * @param {string} field - Indicates the column name for sorting the return list. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + orderByDesc(field: string): RdbPredicatesV9; + + /** + * Restricts each row of the query result to be unique. + * + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + distinct(): RdbPredicatesV9; + + /** + * Restricts the max number of return records. + * + * @param {number} value - Indicates the max length of the return list. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + limitAs(value: number): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to specify the start position of the returned result. + * + * @note Use this method together with limit(int). + * @param {number} rowOffset - Indicates the start position of the returned result. The value is a positive integer. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + offsetAs(rowOffset: number): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to group query results by specified columns. + * + * @param {Array} fields - Indicates the specified columns by which query results are grouped. + * @returns {RdbPredicatesV9} - the SQL query statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + groupBy(fields: Array): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to specify the index column. + * + * @note Before using this method, you need to create an index column. + * @param {string} field - Indicates the name of the index column. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + indexedBy(field: string): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to match the specified field whose data type is ValueType array and values + * are within a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + in(field: string, value: Array): RdbPredicatesV9; + + /** + * Configures RdbPredicatesV9 to match the specified field whose data type is ValueType array and values + * are out of a given range. + * + * @param {string} field - Indicates the column name in the database table. + * @param {Array} value - Indicates the values to match with {@link RdbPredicatesV9}. + * @returns {RdbPredicatesV9} - the SQL statement with the specified {@link RdbPredicatesV9}. + * @throws {BusinessError} 401 - if the parameter type is incorrect. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + notIn(field: string, value: Array): RdbPredicatesV9; +} + +export type ResultSet = _ResultSet; +export type ResultSetV9 = _ResultSetV9; } export default rdb; diff --git a/api/@ohos.deviceInfo.d.ts b/api/@ohos.deviceInfo.d.ts index 6c1f0bea3249026502df6f6a3eee34055c4463dc..55067063a7f0170ebbb2ae7bb69a9308e8afd820 100644 --- a/api/@ohos.deviceInfo.d.ts +++ b/api/@ohos.deviceInfo.d.ts @@ -87,6 +87,7 @@ declare namespace deviceInfo { /** * Obtains the device serial number represented by a string. + * @permission ohos.permission.sec.ACCESS_UDID * @syscap SystemCapability.Startup.SystemInfo * @since 6 */ @@ -234,6 +235,7 @@ declare namespace deviceInfo { const buildRootHash: string; /** * Obtains the device udid. + * @permission ohos.permission.sec.ACCESS_UDID * @syscap SystemCapability.Startup.SystemInfo * @since 7 */ diff --git a/api/@ohos.devicestatus.d.ts b/api/@ohos.devicestatus.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e231cc780b8f9af9caa10b6dfe377077d5e93ed --- /dev/null +++ b/api/@ohos.devicestatus.d.ts @@ -0,0 +1,119 @@ +/* + * 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"; + +/** + * Declares a namespace that provides APIs to report the device status. + * + * @since 9 + * @syscap SystemCapability.Msdp.DeviceStatus + * @import import DeviceStatus from '@ohos.DeviceStatus' + */ +declare namespace deviceStatus { + /** + * Declares a response interface to receive the device status. + * + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + interface ActivityResponse { + state: ActivityState; + } + + /** + * Declares the device status type. + * + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + type ActivityType = 'still' | 'relativeStill'; + + /** + * Enumerates the device status events. + * + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + enum ActivityEvent { + /** + * Event indicating entering device status. + */ + ENTER = 1, + + /** + * Event indicating exiting device status. + */ + EXIT = 2, + + /** + * Event indicating entering and exiting device status. + */ + ENTER_EXIT = 3 + } + + /** + * Declares a response interface to receive the device status. + * + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + enum ActivityState { + /** + * Entering device status. + */ + ENTER = 1, + + /** + * Exiting device status. + */ + EXIT = 2 + } + + /** + * Subscribes to the device status. + * + * @param activity Indicates the device status type. For details, see {@code type: ActivityType}. + * @param event Indicates the device status event. + * @param reportLatencyNs Indicates the event reporting period. + * @param callback Indicates the callback for receiving reported data. + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + function on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback): void; + + /** + * Obtains the device status. + * + * @param activity Indicates the device status type. For details, see {@code type: ActivityType}. + * @param callback Indicates the callback for receiving reported data. + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + function once(activity: ActivityType, callback: Callback): void; + + /** + * Unsubscribes from the device status. + * + * @param activity Indicates the device status type. For details, see {@code type: ActivityType}. + * @param event Indicates the device status event. + * @param callback Indicates the callback for receiving reported data. + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + function off(activity: ActivityType, event: ActivityEvent, callback?: Callback): void; +} + +export default deviceStatus; diff --git a/api/@ohos.distributedBundle.d.ts b/api/@ohos.distributedBundle.d.ts index beaf21575af453570f75e4e5c38aab81f6ac4897..a00959bcb328add68fb01834a03cfa4db9790c90 100644 --- a/api/@ohos.distributedBundle.d.ts +++ b/api/@ohos.distributedBundle.d.ts @@ -15,7 +15,7 @@ import { AsyncCallback } from './basic'; import { ElementName } from './bundle/elementName'; -import { RemoteAbilityInfo as _RemoteAbilityInfo } from './bundle/remoteAbilityInfo'; +import { RemoteAbilityInfo } from './bundle/remoteAbilityInfo'; /** * distributedBundle. @@ -24,6 +24,8 @@ import { RemoteAbilityInfo as _RemoteAbilityInfo } from './bundle/remoteAbilityI * @syscap SystemCapability.BundleManager.DistributedBundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.distributeBundle */ declare namespace distributedBundle { /** @@ -35,6 +37,8 @@ import { RemoteAbilityInfo as _RemoteAbilityInfo } from './bundle/remoteAbilityI * @return Returns the ability info of the remote device. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @systemapi + * @deprecated since 9 + * @useinstead ohos.bundle.distributeBundle#getRemoteAbilityInfo */ function getRemoteAbilityInfo(elementName: ElementName, callback: AsyncCallback): void; function getRemoteAbilityInfo(elementName: ElementName): Promise; @@ -48,45 +52,10 @@ import { RemoteAbilityInfo as _RemoteAbilityInfo } from './bundle/remoteAbilityI * @return Returns the ability infos of the remote device. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED * @systemapi + * @deprecated since 9 + * @useinstead ohos.bundle.distributeBundle#getRemoteAbilityInfo */ function getRemoteAbilityInfos(elementNames: Array, callback: AsyncCallback>): void; function getRemoteAbilityInfos(elementNames: Array): Promise>; - - /** - * Obtains information about the ability info of the remote device. - * - * @since 9 - * @syscap SystemCapability.BundleManager.DistributedBundleFramework - * @param elementName Indicates the elementName. - * @param locale Indicates the locale info - * @return Returns the ability info of the remote device. - * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED - * @systemapi - */ - function getRemoteAbilityInfo(elementName: ElementName, locale: string, callback: AsyncCallback): void; - function getRemoteAbilityInfo(elementName: ElementName, locale: string): Promise; - - /** - * Obtains information about the ability infos of the remote device. - * - * @since 9 - * @syscap SystemCapability.BundleManager.DistributedBundleFramework - * @param elementNames Indicates the elementNames, Maximum array length ten. - * @param locale Indicates the locale info - * @return Returns the ability infos of the remote device. - * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED - * @systemapi - */ - function getRemoteAbilityInfos(elementNames: Array, locale: string, callback: AsyncCallback>): void; - function getRemoteAbilityInfos(elementNames: Array, locale: string): Promise>; - - /** - * Contains basic remote ability information. - * - * @since 9 - * @syscap SystemCapability.BundleManager.DistributedBundleFramework - * @systemapi hide this for inner system use - */ - export type RemoteAbilityInfo = _RemoteAbilityInfo; } export default distributedBundle; \ No newline at end of file diff --git a/api/@ohos.distributedHardware.deviceManager.d.ts b/api/@ohos.distributedHardware.deviceManager.d.ts index f9073f101a47eec65066f63f7fe7a4f2edae7565..f388aecaefe41f7f3027ce76cb8bf89623be1c00 100644 --- a/api/@ohos.distributedHardware.deviceManager.d.ts +++ b/api/@ohos.distributedHardware.deviceManager.d.ts @@ -356,7 +356,6 @@ declare namespace deviceManager { /** * Obtains a list of trusted devices. * - * @throws {BusinessError} 401 - Input parameter error. * @throws {BusinessError} 11600101 - Failed to execute the function. * @return Returns a list of trusted devices. * @systemapi this method can be used only by system applications. @@ -378,7 +377,6 @@ declare namespace deviceManager { * Obtains a list of trusted devices. * * @since 8 - * @throws {BusinessError} 401 - Input parameter error. * @return Returns a list of trusted devices. * @systemapi this method can be used only by system applications. */ @@ -388,7 +386,6 @@ declare namespace deviceManager { * Obtains local device info * * @since 8 - * @throws {BusinessError} 401 - Input parameter error. * @throws {BusinessError} 11600101 - Failed to execute the function. * @return Returns local device info. * @systemapi this method can be used only by system applications. @@ -410,7 +407,6 @@ declare namespace deviceManager { * Obtains local device info * * @since 8 - * @throws {BusinessError} 401 - Input parameter error. * @return Returns local device info. * @systemapi this method can be used only by system applications. */ diff --git a/api/@ohos.EnterpriseAdminExtensionAbility.d.ts b/api/@ohos.enterprise.EnterpriseAdminExtensionAbility.d.ts similarity index 97% rename from api/@ohos.EnterpriseAdminExtensionAbility.d.ts rename to api/@ohos.enterprise.EnterpriseAdminExtensionAbility.d.ts index e968d3ff4b63904ae23b6766240923e55e17cfbb..6cd8d1a83faf1d7d5c206eeee78a4c899824c785 100644 --- a/api/@ohos.EnterpriseAdminExtensionAbility.d.ts +++ b/api/@ohos.enterprise.EnterpriseAdminExtensionAbility.d.ts @@ -18,6 +18,7 @@ * * @since 9 * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi * @StageModelOnly */ export default class EnterpriseAdminExtensionAbility { @@ -26,15 +27,17 @@ export default class EnterpriseAdminExtensionAbility { * * @since 9 * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi * @StageModelOnly */ onAdminEnabled(): void; - + /** * Called back when an application is disabled. * * @since 9 * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi * @StageModelOnly */ onAdminDisabled(): void; diff --git a/api/@ohos.enterpriseDeviceManager.d.ts b/api/@ohos.enterprise.adminManager.d.ts similarity index 94% rename from api/@ohos.enterpriseDeviceManager.d.ts rename to api/@ohos.enterprise.adminManager.d.ts index 612d2d7d12553a5f05b7779531abb5517c812356..52fded9d1622b440600fdb953458e1199f32ee76 100644 --- a/api/@ohos.enterpriseDeviceManager.d.ts +++ b/api/@ohos.enterprise.adminManager.d.ts @@ -14,44 +14,70 @@ */ import { AsyncCallback, Callback } from "./basic"; -import { DeviceSettingsManager as _DeviceSettingsManager } from "./enterpriseDeviceManager/DeviceSettingsManager"; -import Want from "./@ohos.application.Want"; +import Want from "./@ohos.app.ability.Want"; /** - * enterprise device manager. - * @name enterpriseDeviceManager - * @since 9 + * This module provides the capability to manage the administrator of the enterprise devices. + * @namespace adminManager * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @since 9 */ -declare namespace enterpriseDeviceManager { +declare namespace adminManager { /** - * @name EnterpriseInfo - * @since 9 + * Provides the enterprise information. + * @typedef EnterpriseInfo * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @since 9 */ export interface EnterpriseInfo { + /** + * The name of enterprise. + * @type {string} + * @since 9 + */ name: string; + + /** + * The description of enterprise. + * @type {string} + * @since 9 + */ description: string; } /** - * @name DeviceSettingsManager - * @since 9 + * Enum for type of administrator. + * @enum {number} * @syscap SystemCapability.Customization.EnterpriseDeviceManager - */ - export type DeviceSettingsManager = _DeviceSettingsManager - - /** - * @name AdminType + * @systemapi * @since 9 - * @syscap SystemCapability.Customization.EnterpriseDeviceManager */ export enum AdminType { + /** + * The value of normal administrator. + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @since 9 + */ ADMIN_TYPE_NORMAL = 0x00, + + /** + * The value of super administrator. + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @since 9 + */ ADMIN_TYPE_SUPER = 0x01 } + /** + * Enum for managed event + * @enum {number} + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @since 9 + */ export enum ManagedEvent { /** @@ -255,7 +281,7 @@ declare namespace enterpriseDeviceManager { * Get information of the administrator's enterprise. * @param { Want } admin - admin indicates the administrator ability information. * @param { AsyncCallback } callback - callback contained the enterprise info of administrator. - * @throws { BusinessError } 9200001 - the applicayion is not an administrator of the device. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. * @throws { BusinessError } 401 - invalid input parameter. * @syscap SystemCapability.Customization.EnterpriseDeviceManager * @systemapi @@ -268,7 +294,7 @@ declare namespace enterpriseDeviceManager { * Get information of the administrator's enterprise. * @param { Want } admin - admin indicates the administrator ability information. * @returns { Promise } promise contained the enterprise info of administrator. - * @throws { BusinessError } 9200001 - the applicayion is not an administrator of the device. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. * @throws { BusinessError } 401 - invalid input parameter. * @syscap SystemCapability.Customization.EnterpriseDeviceManager * @systemapi @@ -280,10 +306,11 @@ declare namespace enterpriseDeviceManager { /** * Set the information of the administrator's enterprise. * Only the administrator app can call this method. + * @permission ohos.permission.SET_ENTERPRISE_INFO * @param { Want } admin - admin indicates the administrator ability information. * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. * @param { AsyncCallback } callback - the callback of setEnterpriseInfo. - * @throws { BusinessError } 9200001 - the applicayion is not an administrator of the device. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. * @throws { BusinessError } 201 - the application does not have permission to call this function. * @throws { BusinessError } 401 - invalid input parameter. * @syscap SystemCapability.Customization.EnterpriseDeviceManager @@ -300,7 +327,7 @@ declare namespace enterpriseDeviceManager { * @param { Want } admin - admin indicates the administrator ability information. * @param { EnterpriseInfo } enterpriseInfo - enterpriseInfo indicates the enterprise information of the calling application. * @returns { Promise } the promise returned by the setEnterpriseInfo. - * @throws { BusinessError } 9200001 - the applicayion is not an administrator of the device. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. * @throws { BusinessError } 201 - the application does not have permission to call this function. * @throws { BusinessError } 401 - invalid input parameter. * @syscap SystemCapability.Customization.EnterpriseDeviceManager @@ -334,16 +361,6 @@ declare namespace enterpriseDeviceManager { */ 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; - /** * Subscribes the managed event of admin. * @permission ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT @@ -413,4 +430,4 @@ declare namespace enterpriseDeviceManager { function unsubscribeManagedEvent(admin: Want, managedEvents: Array): Promise; } -export default enterpriseDeviceManager; \ No newline at end of file +export default adminManager; \ No newline at end of file diff --git a/api/enterpriseDeviceManager/DeviceSettingsManager.d.ts b/api/@ohos.enterprise.dateTimeManager.d.ts similarity index 48% rename from api/enterpriseDeviceManager/DeviceSettingsManager.d.ts rename to api/@ohos.enterprise.dateTimeManager.d.ts index 4187a3f5f1334bca55d1c787babbb12b58b9c654..c9186257c5d465a0a1d54a9926f7f37c0c005584 100644 --- a/api/enterpriseDeviceManager/DeviceSettingsManager.d.ts +++ b/api/@ohos.enterprise.dateTimeManager.d.ts @@ -13,25 +13,45 @@ * limitations under the License. */ -import { AsyncCallback, Callback } from "./../basic"; -import Want from "./../@ohos.application.Want"; +import { AsyncCallback } from "./basic"; +import Want from "./@ohos.app.ability.Want"; /** - * @name Offers set settings policies on the devices. - * @since 9 + * This module provides the capability to manage the datetime of the enterprise devices. + * @namespace dateTimeManager. * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @since 9 */ -export interface DeviceSettingsManager { +declare namespace dateTimeManager { + + /** + * Sets the system time. + * This function can be called by a super administrator. + * @permission ohos.permission.ENTERPRISE_SET_DATETIME + * @param { Want } admin - admin indicates the administrator ability information. + * @param { number } time - time indicates rhe target time stamp (ms). + * @param { AsyncCallback } callback - the callback of setDateTime. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. + * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. + * @throws { BusinessError } 201 - the application does not have permission to call this function. + * @throws { BusinessError } 401 - invalid input parameter. + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @stagemodelonly + * @since 9 + */ + function setDateTime(admin: Want, time: number, callback: AsyncCallback): void; /** * Sets the system time. * This function can be called by a super administrator. - * @permission ohos.permission.EDM_MANAGE_DATETIME + * @permission ohos.permission.ENTERPRISE_SET_DATETIME * @param { Want } admin - admin indicates the administrator ability information. * @param { number } time - time indicates rhe target time stamp (ms). * @returns { Promise } the promise returned by the setDateTime. - * @throws { BusinessError } 9200001 - the applicayion is not an administrator of the device. - * @throws { BusinessError } 9200002 - the administrator applicayion does not have permission to manage the device. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. + * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. * @throws { BusinessError } 201 - the application does not have permission to call this function. * @throws { BusinessError } 401 - invalid input parameter. * @syscap SystemCapability.Customization.EnterpriseDeviceManager @@ -39,6 +59,7 @@ export interface DeviceSettingsManager { * @stagemodelonly * @since 9 */ - setDateTime(admin: Want, time: number, callback: AsyncCallback): void; - setDateTime(admin: Want, time: number): Promise; -} \ No newline at end of file + function setDateTime(admin: Want, time: number): Promise; +} + +export default dateTimeManager; \ No newline at end of file diff --git a/api/@ohos.enterprise.deviceInfo.d.ts b/api/@ohos.enterprise.deviceInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1ebb9170a7ee43c40a61bd19597fb50340871e5 --- /dev/null +++ b/api/@ohos.enterprise.deviceInfo.d.ts @@ -0,0 +1,63 @@ +/* + * 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 Want from "./@ohos.app.ability.Want"; + +/** + * This module provides the capability to manage the device info of the enterprise devices. + * @namespace deviceInfo. + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @since 9 + */ +declare namespace deviceInfo { + + /** + * Gets the device serial. + * This function can be called by a super administrator. + * @permission ohos.permission.ENTERPRISE_GET_DEVICE_INFO + * @param { Want } admin - admin indicates the administrator ability information. + * @param { AsyncCallback } callback - the callback of getDeviceSerial. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. + * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. + * @throws { BusinessError } 201 - the application does not have permission to call this function. + * @throws { BusinessError } 401 - invalid input parameter. + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @stagemodelonly + * @since 9 + */ + function getDeviceSerial(admin: Want, callback: AsyncCallback): void; + + /** + * Gets the device serial. + * This function can be called by a super administrator. + * @permission ohos.permission.ENTERPRISE_GET_DEVICE_INFO + * @param { Want } admin - admin indicates the administrator ability information. + * @returns { Promise } the promise returned by the getDeviceSerial. + * @throws { BusinessError } 9200001 - the application is not an administrator of the device. + * @throws { BusinessError } 9200002 - the administrator application does not have permission to manage the device. + * @throws { BusinessError } 201 - the application does not have permission to call this function. + * @throws { BusinessError } 401 - invalid input parameter. + * @syscap SystemCapability.Customization.EnterpriseDeviceManager + * @systemapi + * @stagemodelonly + * @since 9 + */ + function getDeviceSerial(admin: Want): Promise; +} + +export default deviceInfo; \ No newline at end of file diff --git a/api/@ohos.faultLogger.d.ts b/api/@ohos.faultLogger.d.ts index 45a78fecd3ab6b070430f9b89e513496107682e5..5162e428f61123758a8c00af29366d2a3d6774c0 100644 --- a/api/@ohos.faultLogger.d.ts +++ b/api/@ohos.faultLogger.d.ts @@ -15,125 +15,159 @@ import { AsyncCallback } from "./basic"; - /** * This module provides the capability to query faultlog data. - * - * @since 8 + * @namespace FaultLogger * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger - * @import import sensor from '@ohos.faultlogger' + * @since 8 */ - declare namespace FaultLogger { /** * The type of fault type. - * @since 8 + * @enum { number } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ enum FaultType { /** * NO_SPECIFIC log type not distinguished. - * @since 8 * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ NO_SPECIFIC = 0, /** - * CPP_CRASH CPP crash log type - * @since 8 + * CPP_CRASH CPP crash log type. * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ CPP_CRASH = 2, /** - * JS_CRASH JS crash log type - * @since 8 + * JS_CRASH JS crash log type. * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ JS_CRASH = 3, /** - * APP_FREEZE app feeeze log type - * @since 8 + * APP_FREEZE app feeeze log type. * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ APP_FREEZE = 4, } /** - * Query the result of the current application FaultLog in callback Mode - * @since 8 + * Query the result of the current application FaultLog in callback Mode. + * @param faultType Fault type to query + * @param callback Faultlog information data callback function * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger - * @param faultType fault type to query - * @param callback faultlog information data callback function + * @since 8 + * @deprecated since 9 + * @useinstead ohos.faultlogger/FaultLogger#query */ function querySelfFaultLog(faultType: FaultType, callback: AsyncCallback>) : void; /** * Query the result of the current application FaultLog in return promise mode. - * @since 8 + * @param faultType Fault type to query + * @returns return faultlog information data by promise * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger - * @param faultType fault type to query - * @return return faultlog information data by promise + * @since 8 + * @deprecated since 9 + * @useinstead ohos.faultlogger/FaultLogger#query */ function querySelfFaultLog(faultType: FaultType) : Promise>; /** - * FaultLog information data structure - * @since 8 + * Query the result of the current application FaultLog in callback Mode. + * @param faultType Fault type to query + * @param callback Faultlog information data callback function + * @throws { BusinessError } 401 - the parameter check failed + * @throws { BusinessError } 801 - the specified SystemCapability name was not found + * @throws { BusinessError } 10600001 - the service is not running or broken * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 9 + */ + function query(faultType: FaultType, callback: AsyncCallback>) : void; + + /** + * Query the result of the current application FaultLog in return promise mode. + * @param faultType Fault type to query + * @returns return faultlog information data by promise + * @throws { BusinessError } 401 - the parameter check failed + * @throws { BusinessError } 801 - the specified SystemCapability name was not found + * @throws { BusinessError } 10600001 - the service is not running or broken + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 9 + */ + function query(faultType: FaultType) : Promise>; + + /** + * FaultLog information data structure. + * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ interface FaultLogInfo { /** - * pid Process id - * @since 8 + * Process id. + * @type { number } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ pid: number; /** - * uid user id - * @since 8 + * User id. + * @type { number } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ uid: number; /** - * type fault type - * @since 8 + * Fault type. + * @type { FaultType } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ type: FaultType; /** - * second level timestamp - * @since 8 + * Second level timestamp. + * @type { number } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ timestamp: number; /** - * reason fault reason - * @since 8 + * Fault reason. + * @type { string } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ reason: string; /** - * module fault module - * @since 8 + * Fault module. + * @type { string } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ module: string; /** - * summary fault summary - * @since 8 + * Fault summary. + * @type { string } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ summary: string; /** - * fullLog fault log - * @since 8 + * Fault log. + * @type { string } * @syscap SystemCapability.HiviewDFX.Hiview.FaultLogger + * @since 8 */ fullLog: string; } diff --git a/api/@ohos.file.fs.d.ts b/api/@ohos.file.fs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..17d95750ebfff4cb768c9b086f801d08c16b2f02 --- /dev/null +++ b/api/@ohos.file.fs.d.ts @@ -0,0 +1,496 @@ +/* + * 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' + +export default fileIo; + +/** + * fileio + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @import import fileio from '@ohos.file.js'; + */ +declare namespace fileIo { + export { open }; + export { openSync }; + export { read }; + export { readSync }; + export { stat }; + export { statSync }; + export { truncate }; + export { truncateSync }; + export { write }; + export { writeSync }; + export { File }; + export { OpenMode }; + export { Stat }; + + /** + * Mode Indicates the open flags. + * @since 9 + * @syscap SystemCapability.FileManagement.File.FileIO + */ + namespace OpenMode { + const READ_ONLY = 0o0; // Read only Permission + const WRITE_ONLY = 0o1; // Write only Permission + const READ_WRITE = 0o2; // Write and Read Permission + const CREATE = 0o100; // If not exist, create file + const TRUNC = 0o1000; // File truncate len 0 + const APPEND = 0o2000; // File append write + const NONBLOCK = 0o4000; // File open in nonblocking mode + const DIR = 0o200000; // File is Dir + const NOFOLLOW = 0o400000; // File is not symbolic link + const SYNC = 0o4010000; // SYNC IO + } +} + +/** + * Open file. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @function open + * @param {string} path - path. + * @param {number} [mode = OpenMode.READ_ONLY] - mode. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function open(path: string, mode?: number): Promise; +declare function open(path: string, callback: AsyncCallback): void; +declare function open(path: string, mode: number, callback: AsyncCallback): void; +/** + * Open file with sync interface. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @function openSync + * @param {string} path - path. + * @param {number} [mode = OpenMode.READ_ONLY] - mode. + * @returns {File} open fd + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900006 - No such device or address + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900014 - Device or resource busy + * @throws { BusinessError } 13900015 - File exists + * @throws { BusinessError } 13900017 - No such device + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900022 - Too many open files + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900029 - Resource deadlock would occur + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function openSync(path: string, mode?: number): File; + +/** + * Read file. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @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 = 0] - length. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function read(fd: number, buffer: ArrayBuffer, options?: { + offset?: number; + length?: number; +}): Promise +declare function read(fd: number, buffer: ArrayBuffer, callback: AsyncCallback): void; +declare function read(fd: number, buffer: ArrayBuffer, options: { + offset?: number; + length?: number; +}, callback: AsyncCallback): void; +/** + * Read file with sync interface. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @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 = 0] - length. + * @returns {number} number of bytesRead + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function readSync(fd: number, buffer: ArrayBuffer, options?: { + offset?: number; + length?: number; +}): number; + +/** + * Get file information. + * @static + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @param {string | number} file - path or file descriptor. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function stat(file: string | number): Promise; +declare function stat(file: string | number, callback: AsyncCallback): void; +/** + * Get file information with sync interface. + * @static + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @param {string | number} file - path or file descriptor. + * @returns {Stat} stat success + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900011 - Out of memory + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900031 - Function not implemented + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900038 - Value too large for defined data type + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function statSync(file: string | number): Stat; + + /** + * Truncate file. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @function truncate + * @param {string | number} file - path or file descriptor. + * @param {number} [len = 0] - len. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function truncate(file: string | number, len?: number): Promise; +declare function truncate(file: string | number, callback: AsyncCallback): void; +declare function truncate(file: string | number, len: number, callback: AsyncCallback): void; +/** + * Truncate file with sync interface. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @function truncateSync + * @param {string | number} file - path or file descriptor. + * @param {number} [len = 0] - len. + * @returns {void} truncate success + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900002 - No such file or directory + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900012 - Permission denied + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900018 - Not a directory + * @throws { BusinessError } 13900019 - Is a directory + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900023 - Text file busy + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900027 - Read-only file system + * @throws { BusinessError } 13900030 - File name too long + * @throws { BusinessError } 13900033 - Too many symbolic links encountered + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function truncateSync(file: string | number, len?: number): void; + +/** + * Write file. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @function write + * @param {number} fd - file descriptor. + * @param {ArrayBuffer | string} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = 0] - length. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback return Promise otherwise return void + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function write(fd: number, buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: 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; + encoding?: string; +}, callback: AsyncCallback): void; +/** + * Write file with sync interface. + * + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @function writeSync + * @param {number} fd - file descriptor. + * @param {ArrayBuffer | string} buffer - file descriptor. + * @param {Object} [options] - options. + * @param {number} [options.offset = 0] - offset. + * @param {number} [options.length = 0] - length. + * @param {string} [options.encoding = 'utf-8'] - encoding. + * @returns {number} on success number of bytesRead + * @throws { BusinessError } 13900001 - Operation not permitted + * @throws { BusinessError } 13900004 - Interrupted system call + * @throws { BusinessError } 13900005 - I/O error + * @throws { BusinessError } 13900008 - Bad file descriptor + * @throws { BusinessError } 13900010 - Try again + * @throws { BusinessError } 13900013 - Bad address + * @throws { BusinessError } 13900020 - Invalid argument + * @throws { BusinessError } 13900024 - File too large + * @throws { BusinessError } 13900025 - No space left on device + * @throws { BusinessError } 13900034 - Operation would block + * @throws { BusinessError } 13900041 - Quota exceeded + * @throws { BusinessError } 13900042 - Unknown error + */ +declare function writeSync(fd: number, buffer: ArrayBuffer | string, options?: { + offset?: number; + length?: number; + encoding?: string; +}): number; + +/** + * File object. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + */ +declare interface File { + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly fd: number; +} +/** + * Stat object. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + */ +declare interface Stat { + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly ino: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly mode: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly uid: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly gid: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly size: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly atime: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly mtime: number; + /** + * @type {number} + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @readonly + */ + readonly ctime: number; + /** + * whether path/fd is block device. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isBlockDevice(): boolean; + /** + * whether path/fd is character device. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isCharacterDevice(): boolean; + /** + * whether path/fd is directory. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isDirectory(): boolean; + /** + * whether path/fd is fifo. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isFIFO(): boolean; + /** + * whether path/fd is file. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isFile(): boolean; + /** + * whether path/fd is socket. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isSocket(): boolean; + /** + * whether path/fd is symbolic link. + * @syscap SystemCapability.FileManagement.File.FileIO + * @since 9 + * @returns {boolean} is or not + */ + isSymbolicLink(): boolean; +} diff --git a/api/@ohos.fileManager.d.ts b/api/@ohos.fileManager.d.ts deleted file mode 100644 index 0c273772f674823458919d276af45fd739128b2f..0000000000000000000000000000000000000000 --- a/api/@ohos.fileManager.d.ts +++ /dev/null @@ -1,149 +0,0 @@ - /* - * 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 filemanager; - -/** - * @syscap SystemCapability.FileManagement.UserFileService - * @systemapi - */ -declare namespace filemanager { - export { listFile }; - export { getRoot }; - export { createFile }; - export { FileInfo }; - export { DevInfo }; -} - -/** - * listFile. - * - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @function listFile - * @param {string} path - path. - * @param {string} type - type. - * @param {Object} options - options - * @param {DevInfo} [options.dev = {name: "local"}] - dev name. - * @param {number} [options.offset = 0] - offset. - * @param {number} [options.count = 0] - count. - * @param {AsyncCallback} [callback] - callback. - * @returns {void | Promise} no callback return Promise otherwise return void - * @throws {TypedError} Parameter check failed - * @systemapi - */ -declare function listFile(path: string, type: string, options?: {dev?: DevInfo, offset?: number, count?: number}): Promise; -declare function listFile(path: string, type: string, callback: AsyncCallback): void; -declare function listFile(path: string, type: string, options: {dev?: DevInfo, offset?: number, count?: number}, callback: AsyncCallback): void; - -/** - * getRoot. - * - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @function getRoot - * @param {Object} options - options - * @param {DevInfo} [options.dev = {name: "local"}] - dev name. - * @param {AsyncCallback} [callback] - callback. - * @returns {void | Promise} no callback return Promise otherwise return void - * @throws {TypedError} Parameter check failed - * @systemapi - */ -declare function getRoot(options?: {dev?: DevInfo}): Promise; -declare function getRoot(callback: AsyncCallback): void; -declare function getRoot(options: {dev?: DevInfo}, callback: AsyncCallback): void; - -/** - * createFile. - * - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @function createFile - * @param {string} path - album uri. - * @param {string} filename- file name. - * @param {Object} options - options - * @param {DevInfo} [options.dev = {name: "local"}] - dev name. - * @param {AsyncCallback} [callback] - callback. - * @returns {void | Promise} no callback return Promise otherwise return void - * @throws {TypedError} Parameter check failed - * @systemapi - */ -declare function createFile(path: string, filename: string, options?: {dev?: DevInfo}): Promise; -declare function createFile(path: string, filename: string, callback: AsyncCallback): void; -declare function createFile(path: string, filename: string, options: {dev?: DevInfo}, callback: AsyncCallback): void; - -/** - * FileInfo - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @systemapi - */ -declare interface FileInfo { - /** - * @type {string} - * @readonly - */ - name: string; - /** - * @type {string} - * @readonly - */ - path: string; - /** - * @type {string} - * @readonly - */ - type: string; - /** - * @type {string} - * @readonly - */ - size: number; - /** - * @type {string} - * @readonly - */ - addedTime: number; - /** - * @type {string} - * @readonly - */ - modifiedTime: number; -} - -/** - * DevInfo - * @note N/A - * @syscap SystemCapability.FileManagement.UserFileService - * @since 9 - * @permission N/A - * @systemapi - */ - declare interface DevInfo { - /** - * @type {string} - */ - name: string; - } diff --git a/api/@ohos.fileio.d.ts b/api/@ohos.fileio.d.ts index 40ce3da3425c0705464b0d39feeaeacac509c57d..5317eb79676630a2451718c685fe7bc550f18f7f 100644 --- a/api/@ohos.fileio.d.ts +++ b/api/@ohos.fileio.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -84,7 +84,6 @@ declare namespace fileIO { export { writeSync }; export { Dir }; export { Dirent }; - export { ReadOut }; export { Stat }; export { Stream }; @@ -281,7 +280,8 @@ declare function chmodSync(path: string, mode: number): void; * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 7 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.truncate * @function ftruncate * @param {number} fd - fd. * @param {number} [len = 0] - len. @@ -298,7 +298,8 @@ declare function ftruncate(fd: number, len: number, callback: AsyncCallback): void; * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 7 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.statSync * @function fstatSync * @param {number} fd - fd. * @returns {Stat} @@ -620,7 +623,8 @@ declare function mkdtempSync(prefix: string): string; * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 7 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.open * @function open * @param {string} path - path. * @param {number} [flags = 0] - flags. @@ -639,7 +643,8 @@ declare function open(path: string, flags: number, mode: number, callback: Async * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.openSync * @function openSync * @param {string} path - path. * @param {number} [flags = 0] - flags. @@ -727,7 +732,8 @@ declare function readTextSync(filePath: string, options?: { * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.read * @function read * @param {number} fd - file descriptor. * @param {ArrayBuffer} buffer - file descriptor. @@ -756,7 +762,8 @@ declare function read(fd: number, buffer: ArrayBuffer, options: { * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.readSync * @function readSync * @param {number} fd - file descriptor. * @param {ArrayBuffer} buffer - file descriptor. @@ -836,7 +843,8 @@ declare function rmdirSync(path: string): void; * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.stat * @param {string} path - path. * @param {AsyncCallback} [callback] - callback. * @returns {void | Promise} no callback return Promise otherwise return void @@ -850,7 +858,8 @@ declare function stat(path: string, callback: AsyncCallback): void; * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.statSync * @param {string} path - path. * @returns {Stat} stat success * @throws {TypedError | Error} stat fail @@ -892,7 +901,8 @@ declare function symlink(target: string, srcPath: string, callback: AsyncCallbac * @note N/A * @syscap SystemCapability.FileManagement.File.FileIO * @since 7 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.truncate * @function truncate * @param {string} path - path. * @param {number} [len = 0] - len. @@ -909,7 +919,8 @@ declare function truncate(path: string, len: number, callback: AsyncCallback; + displayName?: Array; /** * @type {Array} * @syscap SystemCapability.FileManagement.File.FileIO @@ -1180,7 +1193,7 @@ export type Filter = { * @since 9 * @readonly */ - mimeType: Array; + mimeType?: Array; /** * @type {number} * @syscap SystemCapability.FileManagement.File.FileIO @@ -1188,7 +1201,7 @@ export type Filter = { * @since 9 * @readonly */ - fileSizeOver: number; + fileSizeOver?: number; /** * @type {number} * @syscap SystemCapability.FileManagement.File.FileIO @@ -1196,7 +1209,7 @@ export type Filter = { * @since 9 * @readonly */ - lastModifiedAfter: number; + lastModifiedAfter?: number; /** * @type {boolean} * @syscap SystemCapability.FileManagement.File.FileIO @@ -1204,14 +1217,15 @@ export type Filter = { * @since 9 * @readonly */ - excludeMedia: boolean; + excludeMedia?: boolean; } /** * Stat * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 - * @permission N/A + * @deprecated since 9 + * @useinstead ohos.file.fs.Stat */ declare interface Stat { /** @@ -1545,6 +1559,7 @@ declare interface Stream { * ReadOut * @syscap SystemCapability.FileManagement.File.FileIO * @since 6 + * @deprecated since 9 * @permission N/A */ declare interface ReadOut { diff --git a/api/@ohos.filemanagement.userFileManager.d.ts b/api/@ohos.filemanagement.userFileManager.d.ts index 863d2baa402312a617d0119ae0e71aa76ddf9dee..2789f8774165a819d43374167b8b581a4c4ecbbf 100644 --- a/api/@ohos.filemanagement.userFileManager.d.ts +++ b/api/@ohos.filemanagement.userFileManager.d.ts @@ -21,6 +21,7 @@ import dataSharePredicates from './@ohos.data.dataSharePredicates'; /** * @name userFileManager * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @import Import userFileManager from '@ohos.filemanagement.userFileManager' */ @@ -28,6 +29,7 @@ declare namespace userFileManager { /** * Returns an instance of UserFileManager * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @StageModelOnly * @param context Hap context information @@ -38,24 +40,28 @@ declare namespace userFileManager { /** * Enumeration types for different kinds of Files * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ enum FileType { /** * Image file type * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ IMAGE = 1, /** * Video file type * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ VIDEO, /** * Audio file type * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ AUDIO @@ -63,17 +69,22 @@ declare namespace userFileManager { /** * Indicates the type of file asset member. + * @since 9 + * @systemapi */ type MemberType = number | string | boolean; /** * Indicates the type of notify event. + * @since 9 + * @systemapi */ type ChangeEvent = 'deviceChange' | 'albumChange' | 'imageChange' | 'audioChange' | 'videoChange' | 'remoteFileChange'; /** * Provides methods to encapsulate file attributes. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @import Import userFileManager from '@ohos.filemanagement.userFileManager' */ @@ -81,24 +92,28 @@ declare namespace userFileManager { /** * URI of the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ readonly uri: string; /** * File type, for example, IMAGE, VIDEO, AUDIO * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ readonly fileType: FileType; /** * Display name (with a file name extension) of the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ displayName: string; /** * Return the fileasset member parameter. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param member the name of the parameter. for example : get(ImageVideoKey.URI) */ @@ -106,6 +121,7 @@ declare namespace userFileManager { /** * Set the fileasset member parameter. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param member The name of the parameter. only TITLE can be changed * @param string The value of the parameter. @@ -115,6 +131,7 @@ declare namespace userFileManager { /** * Modify meta data where the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO * @param callback No value will be returned. @@ -123,6 +140,7 @@ declare namespace userFileManager { /** * Modify meta data where the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO */ @@ -130,6 +148,7 @@ declare namespace userFileManager { /** * Open the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO or ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO * @param mode Mode for open, for example: rw, r, w. @@ -139,6 +158,7 @@ declare namespace userFileManager { /** * Open the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO or ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO * @param mode Mode for open, for example: rw, r, w. @@ -147,6 +167,7 @@ declare namespace userFileManager { /** * Close the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param fd Fd of the file which had been opened * @param callback No value will be returned. @@ -155,6 +176,7 @@ declare namespace userFileManager { /** * Close the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param fd Fd of the file which had been opened */ @@ -162,6 +184,7 @@ declare namespace userFileManager { /** * Get thumbnail of the file when the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO * @param callback Callback used to return the thumbnail's pixelmap. @@ -170,6 +193,7 @@ declare namespace userFileManager { /** * Get thumbnail of the file when the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO * @param size Thumbnail's size @@ -179,6 +203,7 @@ declare namespace userFileManager { /** * Get thumbnail of the file when the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO or ohos.permission.READ_AUDIO * @param size Thumbnail's size @@ -187,6 +212,7 @@ declare namespace userFileManager { /** * Set favorite for the file when the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO * @param isFavorite True is favorite file, false is not favorite file @@ -196,6 +222,7 @@ declare namespace userFileManager { /** * Set favorite for the file when the file is located. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core ** @permission ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.WRITE_AUDIO * @param isFavorite True is favorite file, false is not favorite file @@ -206,60 +233,70 @@ declare namespace userFileManager { /** * Describes AUDIO TYPE FetchOptions's predicate * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ enum AudioKey { /** * File uri * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ URI, /** * File name * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DISPLAY_NAME, /** * Date of the file creation * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_ADDED, /** * Modify date of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_MODIFIED, /** * Title of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ TITLE, /** * Artist of the audio file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ ARTIST, /** * Audio album of the audio file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ AUDIOALBUM, /** * Duration of the audio file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DURATION, /** * Favorite state of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ FAVORITE, @@ -268,78 +305,91 @@ declare namespace userFileManager { /** * Describes Image, Video TYPE FetchOptions's predicate * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ enum ImageVideoKey { /** * File uri * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ URI, /** * File type of the Asset * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ FILE_TYPE, /** * File name * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DISPLAY_NAME, /** * Date of the file creation * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_ADDED, /** * Modify date of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_MODIFIED, /** * Title of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ TITLE, /** * Duration of the audio and video file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DURATION, /** * Width of the image file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ WIDTH, /** * Height of the image file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ HEIGHT, /** * Date taken of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_TAKEN, /** * Orientation of the image file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ ORIENTATION, /** * Favorite state of the file * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ FAVORITE, @@ -348,36 +398,42 @@ declare namespace userFileManager { /** * Describes Album TYPE predicate * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ enum AlbumKey { /** * Album uri * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ URI, /** * File type of the Album * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ FILE_TYPE, /** * Album name * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ ALBUM_NAME, /** * Date of the Album creation * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_ADDED, /** * Modify date of the Album * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ DATE_MODIFIED, @@ -385,6 +441,7 @@ declare namespace userFileManager { /** * Fetch parameters + * @systemapi * @since 9 * @syscap SystemCapability.FileManagement.UserFileManager.Core */ @@ -392,6 +449,7 @@ declare namespace userFileManager { /** * Indicates the columns to query. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param fetchColumns Indicates the columns to query. If this parameter is null, only uri, name, fileType will query. */ @@ -399,6 +457,7 @@ declare namespace userFileManager { /** * Predicate to query * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param predicates Indicates filter criteria. */ @@ -408,12 +467,14 @@ declare namespace userFileManager { /** * Fetch parameters * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ interface AlbumFetchOptions { /** * Predicate to query * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param predicates Indicates filter criteria. */ @@ -423,6 +484,7 @@ declare namespace userFileManager { /** * Implements file retrieval. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @import Import userFileManager from '@ohos.filemanagement.userFileManager' */ @@ -430,6 +492,7 @@ declare namespace userFileManager { /** * Obtains the total number of files in the file retrieval result. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @return Total number of files. */ @@ -437,6 +500,7 @@ declare namespace userFileManager { /** * Checks whether the result set points to the last row. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @return Whether the file is the last one. * You need to check whether the file is the last one before calling getNextObject, @@ -446,12 +510,14 @@ declare namespace userFileManager { /** * Releases the FetchResult instance and invalidates it. Other methods cannot be called. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ close(): void; /** * Obtains the first FileAsset in the file retrieval result. This method uses a callback to return the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param callback Callback used to return the file in the format of a FileAsset instance. */ @@ -459,6 +525,7 @@ declare namespace userFileManager { /** * Obtains the first T in the file retrieval result. This method uses a promise to return the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @return A Promise instance used to return the file in the format of a T instance. */ @@ -469,6 +536,7 @@ declare namespace userFileManager { * 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 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param callback Callback used to return the file in the format of a T instance. */ @@ -479,6 +547,7 @@ declare namespace userFileManager { * 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 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @return A Promise instance used to return the file in the format of a T instance. */ @@ -486,6 +555,7 @@ declare namespace userFileManager { /** * Obtains the last T in the file retrieval result. This method uses a callback to return the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param callback Callback used to return the file in the format of a T instance. */ @@ -493,6 +563,7 @@ declare namespace userFileManager { /** * Obtains the last T in the file retrieval result. This method uses a promise to return the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @return A Promise instance used to return the file in the format of a T instance. */ @@ -501,6 +572,7 @@ declare namespace userFileManager { * Obtains the T with the specified index in the file retrieval result. * This method uses a callback to return the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param index Index of the file to obtain. * @throws {BusinessError} 13900020 - if type index is not number @@ -511,6 +583,7 @@ declare namespace userFileManager { * Obtains the T with the specified index in the file retrieval result. * This method uses a promise to return the file. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param index Index of the file to obtain. * @throws {BusinessError} 13900020 - if type index is not number @@ -524,41 +597,48 @@ declare namespace userFileManager { * * @syscap SystemCapability.FileManagement.UserFileManager.Core * @since 9 + * @systemapi */ interface AbsAlbum { /** * Album name. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ albumName: string; /** * Album uri. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ readonly albumUri: string; /** * Date (timestamp) when the album was last modified. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ readonly dateModified: number; /** * File count for the album * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ readonly count: number; /** * CoverUri for the album * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ readonly coverUri: string; /** * Obtains files in an album. This method uses an asynchronous callback to return the files. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO * @param type Detemined which kinds of asset to retrive. @@ -570,6 +650,7 @@ declare namespace userFileManager { /** * Obtains files in an album. This method uses a promise to return the files. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO * @param type Detemined which kinds of asset to retrive. @@ -585,11 +666,13 @@ declare namespace userFileManager { * * @syscap SystemCapability.FileManagement.UserFileManager.Core * @since 9 + * @systemapi */ interface Album extends AbsAlbum { /** * Modify the meta data for the album * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.WRITE_IMAGEVIDEO * @param callback No value will be returned. @@ -598,6 +681,7 @@ declare namespace userFileManager { /** * Modify the meta data for the album * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.WRITE_IMAGEVIDEO */ @@ -609,11 +693,13 @@ declare namespace userFileManager { * * @syscap SystemCapability.FileManagement.UserFileManager.Core * @since 9 + * @systemapi */ interface UserFileManager { /** * Query photo, video assets * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO * @param options retrieval options. @@ -624,6 +710,7 @@ declare namespace userFileManager { /** * Query photo, video assets * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO * @param type Detemined which kinds of asset to retrive. @@ -672,6 +759,7 @@ declare namespace userFileManager { /** * Obtains albums based on the retrieval options. This method uses an asynchronous callback to return. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO * @param options Retrieval options. @@ -682,6 +770,7 @@ declare namespace userFileManager { /** * Obtains albums based on the retrieval options. This method uses a promise to return the albums. * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO * @param options Retrieval options. @@ -714,6 +803,7 @@ declare namespace userFileManager { /** * Query audio assets * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_AUDIO * @param options Retrieval options. @@ -724,6 +814,7 @@ declare namespace userFileManager { /** * Query audio assets * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_AUDIO * @param type Detemined which kinds of asset to retrive. @@ -735,17 +826,18 @@ declare namespace userFileManager { /** * Delete Asset * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO * @param uri Uri of asset * @param callback No value returned * @throws {BusinessError} 13900020 - if type uri is not string - * @systemapi */ delete(uri: string, callback: AsyncCallback): void; /** * Delete Asset * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @permission ohos.permission.READ_IMAGEVIDEO and ohos.permission.WRITE_IMAGEVIDEO or ohos.permission.READ_AUDIO and ohos.permission.WRITE_AUDIO * @param uri Uri of asset @@ -756,6 +848,7 @@ declare namespace userFileManager { /** * Turn on mornitor the data changes * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param type One of 'deviceChange','albumChange','imageChange','audioChange','videoChange','remoteFileChange' * @param callback No value returned @@ -764,6 +857,7 @@ declare namespace userFileManager { /** * Turn off mornitor the data changes * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param type One of 'deviceChange','albumChange','imageChange','audioChange','videoChange','remoteFileChange' * @param callback No value returned @@ -804,6 +898,7 @@ declare namespace userFileManager { /** * Release UserFileManager instance * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core * @param callback no value returned */ @@ -811,6 +906,7 @@ declare namespace userFileManager { /** * Release UserFileManager instance * @since 9 + * @systemapi * @syscap SystemCapability.FileManagement.UserFileManager.Core */ release(): Promise; diff --git a/api/@ohos.font.d.ts b/api/@ohos.font.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a7a589ee75b241a90cb9531d2382b0f5307662e --- /dev/null +++ b/api/@ohos.font.d.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 9 + * @import font from '@ohos.font'; + */ +declare namespace font { + /** + * @since 9 + */ + interface FontOptions { + + /** + * The font name to register. + * @since 9 + */ + familyName: string; + + /** + * The path of the font file. + * @since 9 + */ + familySrc: string; + } + /** + * Register a customized font in the FontManager. + * @param options FontOptions + * @since 9 + */ + function registerFont(options: FontOptions):void; + +} + +export default font; diff --git a/api/@ohos.geoLocationManager.d.ts b/api/@ohos.geoLocationManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e6e4a3a6abbd6823cc049c942d276ba47fd22b5 --- /dev/null +++ b/api/@ohos.geoLocationManager.d.ts @@ -0,0 +1,670 @@ +/* + * 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'; + +/** + * Provides interfaces for initiating location requests, ending the location service, + * and obtaining the location result cached by the system. + * + * @since 9 + * @import import geoLocationManager from '@ohos.geoLocationManager' + */ +declare namespace geoLocationManager { + /** + * 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. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + * @throws { BusinessError } 3301100 - The location switch is off. + * @throws { BusinessError } 3301500 - Failed to query the area information. + */ + 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. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + * @throws { BusinessError } 3301100 - The location switch is off. + * @throws { BusinessError } 3301500 - Failed to query the area information. + */ + function off(type: 'countryCodeChange', callback?: Callback): void; + + /** + * Enable location switch + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @param callback Indicates the callback for reporting the error message. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function enableLocation(callback: AsyncCallback): void; + function enableLocation(): Promise; + + /** + * Disable location switch + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @param callback Indicates the callback for reporting the error message. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function disableLocation(callback: AsyncCallback): void; + function disableLocation(): Promise; + + /** + * Obtain the current country code. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @param callback Indicates the callback for reporting the country code. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + * @throws { BusinessError } 3301500 - Failed to query the area information. + */ + function getCountryCode(callback: AsyncCallback): void; + function getCountryCode(): Promise; + + /** + * Enable the geographical location simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param callback Indicates a callback function, which is used to report the error message. + * If the enabling fails, the error message will be carried in the first parameter + * err of AsyncCallback, If enabling succeeds, no data will be returned. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + * @throws { BusinessError } 3301100 - The location switch is off. + */ + function enableLocationMock(callback: AsyncCallback): void; + function enableLocationMock(): Promise; + + /** + * Disable the geographical location simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param callback Indicates a callback function, which is used to report the result + * of disabling the location simulation function. If the disabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If disabling succeeds, no data will be returned. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + * @throws { BusinessError } 3301100 - The location switch is off. + */ + function disableLocationMock(callback: AsyncCallback): void; + function disableLocationMock(): Promise; + + /** + * Set the configuration parameters for location simulation. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param config Indicates the configuration parameters for location simulation. + * @param callback Indicates a callback function, which is used to report the result of setting + * the simulation locations. If the setting fails, the error message will be carried in the first + * parameter err of AsyncCallback. If the setting succeeds, no data will be returned. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + * @throws { BusinessError } 3301100 - The location switch is off. + */ + function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback): void; + function setMockedLocations(config: LocationMockConfig): Promise; + + /** + * Enable the reverse geocoding simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param callback Indicates a callback function, which is used to report the result + * of enabling the reverse geocode simulation function. If the enabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If enabling succeeds, no data will be returned. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function enableReverseGeocodingMock(callback: AsyncCallback): void; + function enableReverseGeocodingMock(): Promise; + + /** + * Disable the reverse geocoding simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param callback Indicates a callback function, which is used to report the result + * of disabling the reverse geocode simulation function. If the disabling fails, the error message will + * be carried in the first parameter err of AsyncCallback, If disabling succeeds, no data will be returned. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function disableReverseGeocodingMock(callback: AsyncCallback): void; + function disableReverseGeocodingMock(): Promise; + + /** + * Set the configuration parameters for simulating reverse geocoding. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + * @param mockInfos Indicates the set of locations and place names to be simulated. + * @param callback Indicates a callback function, which is used to report the result of setting + * the configuration parameters for simulating reverse geocoding. If the setting fails, + * the error message will be carried in the first parameter err of AsyncCallback. + * If the setting succeeds, no data will be returned. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function setReverseGeocodingMockInfo(mockInfos: Array, callback: AsyncCallback): void; + function setReverseGeocodingMockInfo(mockInfos: Array): Promise; + + /** + * Querying location privacy protocol confirmation status. + * + * @since 9 + * @systemapi + * @syscap SystemCapability.Location.Location.Core + * @param type indicates location privacy protocol type. + * @param callback indicates the callback for reporting the location privacy protocol confirmation status. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback): void; + function isLocationPrivacyConfirmed(type: LocationPrivacyType,): Promise; + + /** + * Set location privacy protocol confirmation status. + * + * @since 9 + * @systemapi + * @syscap SystemCapability.Location.Location.Core + * @permission ohos.permission.MANAGE_SECURE_SETTINGS + * @param type indicates location privacy protocol type. + * @param isConfirmed indicates whether the location privacy protocol has been confirmed. + * @param callback Indicates the callback for reporting error message. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - System API is not allowed called by third HAP. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 901 - The operating system or running environment does not support this api. + * @throws { BusinessError } 3301000 - Location service is unavailable. + */ + function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback): void; + function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise; + + /** + * Configuration parameters for simulating reverse geocoding. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + */ + export interface ReverseGeocodingMockInfo { + location: ReverseGeoCodeRequest; + geoAddress: GeoAddress; + } + + /** + * Parameters for configuring the location simulation function. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + * @systemapi + */ + export interface LocationMockConfig { + timeInterval: number; + locations: Array; + } + + /** + * Satellite status information + * + * @since 9 + * @syscap SystemCapability.Location.Location.Gnss + */ + export interface SatelliteStatusInfo { + satellitesNumber: number; + satelliteIds: Array; + carrierToNoiseDensitys: Array; + altitudes: Array; + azimuths: Array; + carrierFrequencies: Array; + } + + /** + * Parameters for requesting to report cache location information + * + * @since 9 + * @syscap SystemCapability.Location.Location.Gnss + */ + export interface CachedGnssLocationsRequest { + reportingPeriodSec: number; + wakeUpCacheQueueFull: boolean; + } + + /** + * Configuring parameters in geo fence requests + * + * @since 9 + * @syscap SystemCapability.Location.Location.Geofence + */ + export interface GeofenceRequest { + priority: LocationRequestPriority; + scenario: LocationRequestScenario; + geofence: Geofence; + } + + /** + * Configuring parameters in geo fence requests + * + * @since 9 + * @syscap SystemCapability.Location.Location.Geofence + */ + export interface Geofence { + latitude: number; + longitude: number; + radius: number; + expiration: number; + } + + /** + * Configuring parameters in reverse geocode requests + * + * @since 9 + * @syscap SystemCapability.Location.Location.Geocoder + */ + export interface ReverseGeoCodeRequest { + locale?: string; + latitude: number; + longitude: number; + maxItems?: number; + } + + /** + * Configuring parameters in geocode requests + * + * @since 9 + * @syscap SystemCapability.Location.Location.Geocoder + */ + export interface GeoCodeRequest { + locale?: string; + description: string; + maxItems?: number; + minLatitude?: number; + minLongitude?: number; + maxLatitude?: number; + maxLongitude?: number; + } + + /** + * Data struct describes geographic locations. + * + * @since 9 + * @syscap SystemCapability.Location.Location.Geocoder + */ + export interface GeoAddress { + /** + * Indicates latitude information. + * A positive value indicates north latitude, + * and a negative value indicates south latitude. + * @since 9 + */ + latitude?: number; + + /** + * Indicates longitude information. + * A positive value indicates east longitude , + * and a negative value indicates west longitude . + * @since 9 + */ + longitude?: number; + + /** + * Indicates language used for the location description. + * zh indicates Chinese, and en indicates English. + * @since 9 + */ + locale?: string; + + /** + * Indicates landmark of the location. + * @since 9 + */ + placeName?: string; + + /** + * Indicates country code. + * @since 9 + */ + countryCode?: string; + + /** + * Indicates country name. + * @since 9 + */ + countryName?: string; + + /** + * Indicates administrative region name. + * @since 9 + */ + administrativeArea?: string; + + /** + * Indicates sub-administrative region name. + * @since 9 + */ + subAdministrativeArea?: string; + + /** + * Indicates locality information. + * @since 9 + */ + locality?: string; + + /** + * Indicates sub-locality information. + * @since 9 + */ + subLocality?: string; + + /** + * Indicates road name. + * @since 9 + */ + roadName?: string; + + /** + * Indicates auxiliary road information. + * @since 9 + */ + subRoadName?: string; + + /** + * Indicates house information. + * @since 9 + */ + premises?: string; + + /** + * Indicates postal code. + * @since 9 + */ + postalCode?: string; + + /** + * Indicates phone number. + * @since 9 + */ + phoneNumber?: string; + + /** + * Indicates website URL. + * @since 9 + */ + addressUrl?: string; + + /** + * Indicates additional information. + * @since 9 + */ + descriptions?: Array; + + /** + * Indicates the amount of additional descriptive information. + * @since 9 + */ + descriptionsSize?: number; + + /** + * Indicates whether it is an mock GeoAddress + * @since 9 + */ + isFromMock?: Boolean; + } + + /** + * Configuring parameters in location requests + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export interface LocationRequest { + priority?: LocationRequestPriority; + scenario?: LocationRequestScenario; + timeInterval?: number; + distanceInterval?: number; + maxAccuracy?: number; + } + + /** + * Configuring parameters in current location requests + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export interface CurrentLocationRequest { + priority?: LocationRequestPriority; + scenario?: LocationRequestScenario; + maxAccuracy?: number; + timeoutMs?: number; + } + + /** + * Provides information about geographic locations + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export interface Location { + /** + * Indicates latitude information. + * A positive value indicates north latitude, + * and a negative value indicates south latitude. + * @since 9 + */ + latitude: number; + + /** + * Indicates Longitude information. + * A positive value indicates east longitude , + * and a negative value indicates west longitude . + * @since 9 + */ + longitude: number; + + /** + * Indicates location altitude, in meters. + * @since 9 + */ + altitude: number; + + /** + * Indicates location accuracy, in meters. + * @since 9 + */ + accuracy: number; + + /** + * Indicates speed, in m/s. + * @since 9 + */ + speed: number; + + /** + * Indicates location timestamp in the UTC format. + * @since 9 + */ + timeStamp: number; + + /** + * Indicates direction information. + * @since 9 + */ + direction: number; + + /** + * Indicates location timestamp since boot. + * @since 9 + */ + timeSinceBoot: number; + + /** + * Indicates additional information. + * @since 9 + */ + additions?: Array; + + /** + * Indicates the amount of additional descriptive information. + * @since 9 + */ + additionSize?: number; + + /** + * Indicates whether it is an mock location. + * @since 9 + */ + isFromMock?: Boolean; + } + + /** + * Enum for location priority + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export enum LocationRequestPriority { + UNSET = 0x200, + ACCURACY, + LOW_POWER, + FIRST_FIX, + } + + /** + * Enum for location scenario + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export enum LocationRequestScenario { + UNSET = 0x300, + NAVIGATION, + TRAJECTORY_TRACKING, + CAR_HAILING, + DAILY_LIFE_SERVICE, + NO_POWER, + } + + /** + * Enum for location privacy type + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + export enum LocationPrivacyType { + OTHERS = 0, + STARTUP, + CORE_LOCATION, + } + + /** + * Location subsystem command structure + * + * @since 9 + * @syscap SystemCapability.Location.Location.Core + */ + 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 geoLocationManager; diff --git a/api/@ohos.geolocation.d.ts b/api/@ohos.geolocation.d.ts index fc4619ebec67618bd8c1ce02da738b5c530a6199..5e0e3cfad1f1ddeec328aaaf0bd36610489a80e5 100644 --- a/api/@ohos.geolocation.d.ts +++ b/api/@ohos.geolocation.d.ts @@ -149,24 +149,6 @@ declare namespace geolocation { */ 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 * @@ -304,127 +286,6 @@ declare namespace geolocation { 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; - - /** - * enable the geographical location simulation function. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - * @param scenario Indicates the scenarios where location simulation is required. - * @param callback Indicates a callback function, which is used to report the result - * of enabling the location simulation function. If the enabling fails, the error message will - * be carried in the first parameter err of AsyncCallback, If enabling succeeds, no data will be returned. - */ - function enableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback): void; - function enableLocationMock(callback: AsyncCallback): void; - function enableLocationMock(scenario: LocationRequestScenario): Promise; - function enableLocationMock(): Promise; - - /** - * disable the geographical location simulation function. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - * @param scenario Indicates the scenarios where location simulation is required. - * @param callback Indicates a callback function, which is used to report the result - * of disabling the location simulation function. If the disabling fails, the error message will - * be carried in the first parameter err of AsyncCallback, If disabling succeeds, no data will be returned. - */ - function disableLocationMock(scenario: LocationRequestScenario, callback: AsyncCallback): void; - function disableLocationMock(callback: AsyncCallback): void; - function disableLocationMock(scenario: LocationRequestScenario): Promise; - function disableLocationMock(): Promise; - - /** - * set the configuration parameters for location simulation. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - * @param config Indicates the configuration parameters for location simulation. - * @param callback Indicates a callback function, which is used to report the result of setting - * the simulation locations. If the setting fails, the error message will be carried in the first - * parameter err of AsyncCallback. If the setting succeeds, no data will be returned. - */ - function setMockedLocations(config: LocationMockConfig, callback: AsyncCallback): void; - function setMockedLocations(config: LocationMockConfig): Promise; - - /** - * enable the reverse geocoding simulation function. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - * @param callback Indicates a callback function, which is used to report the result - * of enabling the reverse geocode simulation function. If the enabling fails, the error message will - * be carried in the first parameter err of AsyncCallback, If enabling succeeds, no data will be returned. - */ - function enableReverseGeocodingMock(callback: AsyncCallback): void; - function enableReverseGeocodingMock(): Promise; - - /** - * disable the reverse geocoding simulation function. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - * @param callback Indicates a callback function, which is used to report the result - * of disabling the reverse geocode simulation function. If the disabling fails, the error message will - * be carried in the first parameter err of AsyncCallback, If disabling succeeds, no data will be returned. - */ - function disableReverseGeocodingMock(callback: AsyncCallback): void; - function disableReverseGeocodingMock(): Promise; - - /** - * set the configuration parameters for simulating reverse geocoding. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - * @param mockInfos Indicates the set of locations and place names to be simulated. - * @param callback Indicates a callback function, which is used to report the result of setting - * the configuration parameters for simulating reverse geocoding. If the setting fails, - * the error message will be carried in the first parameter err of AsyncCallback. - * If the setting succeeds, no data will be returned. - */ - function setReverseGeocodingMockInfo(mockInfos: Array, callback: AsyncCallback): void; - function setReverseGeocodingMockInfo(mockInfos: Array): Promise; - - /** - * configuration parameters for simulating reverse geocoding. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - */ - export interface ReverseGeocodingMockInfo { - location: ReverseGeoCodeRequest; - geoAddress: GeoAddress; - } - - /** - * parameters for configuring the location simulation function. - * - * @since 9 - * @syscap SystemCapability.Location.Location.Core - * @systemapi - */ - export interface LocationMockConfig { - timeInterval: number; - locations: Array; - } - /** * satellite status information * @@ -480,33 +341,6 @@ declare namespace geolocation { expiration: number; } - /** - * querying location privacy protocol confirmation status. - * - * @since 8 - * @systemapi - * @syscap SystemCapability.Location.Location.Core - * @permission ohos.permission.LOCATION - * @param type indicates location privacy protocol type. - * @param callback indicates the callback for reporting the location privacy protocol confirmation status. - */ - function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback): void; - function isLocationPrivacyConfirmed(type: LocationPrivacyType,): Promise; - - /** - * set location privacy protocol confirmation status. - * - * @since 8 - * @systemapi - * @syscap SystemCapability.Location.Location.Core - * @permission ohos.permission.LOCATION - * @param type indicates location privacy protocol type. - * @param isConfirmed indicates whether the location privacy protocol has been confirmed. - * @param callback Indicates the callback for reporting whether the action is set successfully. - */ - function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback): void; - function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise; - /** * configuring parameters in reverse geocode requests * @@ -658,12 +492,6 @@ declare namespace geolocation { * @since 7 */ descriptionsSize?: number; - - /** - * Indicates whether it is an mock GeoAddress - * @since 9 - */ - isFromMock?: Boolean; } /** @@ -766,12 +594,6 @@ declare namespace geolocation { * @since 7 */ additionSize?: number; - - /** - * Indicates whether it is an mock location. - * @since 9 - */ - isFromMock?: Boolean; } /** @@ -812,12 +634,6 @@ declare namespace geolocation { * @permission ohos.permission.LOCATION */ export enum GeoLocationErrorCode { - /** - * Indicates function not supported. - * @since 9 - */ - NOT_SUPPORTED = 100, - /** * Indicates input parameter error. * @since 7 @@ -859,12 +675,6 @@ declare namespace geolocation { * @since 7 */ LOCATION_REQUEST_TIMEOUT_ERROR, - - /** - * Indicates country code query failed. - * @since 9 - */ - QUERY_COUNTRY_CODE_ERROR, } /** @@ -891,30 +701,6 @@ declare namespace geolocation { 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/api/@ohos.graphics.colorSpaceManager.d.ts b/api/@ohos.graphics.colorSpaceManager.d.ts index db7b533a3f1b3a3c6414ae09aa6b90eebb044b41..e73dccbdfbe4a5636cffda75ac11f8c39b9f2e69 100644 --- a/api/@ohos.graphics.colorSpaceManager.d.ts +++ b/api/@ohos.graphics.colorSpaceManager.d.ts @@ -71,63 +71,63 @@ import { AsyncCallback } from './basic'; } /** - * Describes the primary colors red, green, blue and white point - * in each color space map(x, y), in terms of real world chromaticities. + * Describes the primary colors red, green, blue and white point coordinated as (x, y) + * in color space, in terms of real world chromaticities. * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ interface ColorSpacePrimaries { /** - * x value of red color + * Coordinate value x of red color * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ redX: number; /** - * y value of red color + * Coordinate value y of red color * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ redY: number; /** - * x value of green color + * Coordinate value x of green color * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ greenX: number; /** - * y value of green color + * Coordinate value y of green color * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ greenY: number; /** - * x value of blue color + * Coordinate value x of blue color * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ blueX: number; /** - * y value of blue color + * Coordinate value y of blue color * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ blueY: number; /** - * x value of white point + * Coordinate value x of white point * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ whitePointX: number; /** - * y value of white point + * Coordinate value y of white point * @since 9 * @syscap SystemCapability.Graphic.Graphic2D.ColorManager.Core */ @@ -143,18 +143,21 @@ import { AsyncCallback } from './basic'; /** * Get color space type. * @since 9 + * @throws {BusinessError} 18600001 - If param value is abnormal */ getColorSpaceName(): ColorSpace; /** * Get white point(x, y) of color space. * @since 9 + * @throws {BusinessError} 18600001 - If param value is abnormal */ getWhitePoint(): Array; /** * Get gamma value of color space. * @since 9 + * @throws {BusinessError} 18600001 - If param value is abnormal */ getGamma(): number; } @@ -163,6 +166,8 @@ import { AsyncCallback } from './basic'; * Create a color space manager by proviced color space type. * @param colorSpaceName Indicates the type of color space * @since 9 + * @throws {BusinessError} 401 - If param is invalid + * @throws {BusinessError} 18600001 - If param value is abnormal */ function create(colorSpaceName: ColorSpace): ColorSpaceManager; @@ -171,6 +176,8 @@ import { AsyncCallback } from './basic'; * @param primaries Indicates the customized color primaries * @param gamma Indicates display gamma value * @since 9 + * @throws {BusinessError} 401 - If param is invalid + * @throws {BusinessError} 18600001 - If param value is abnormal */ function create(primaries: ColorSpacePrimaries, gamma: number): ColorSpaceManager; } diff --git a/api/@ohos.hiAppEvent.d.ts b/api/@ohos.hiAppEvent.d.ts index 2d694a38b52c27b95ccb2bd50d2edbf8755eeac5..b62cf6f34a704d8c3b7c20fd499b689e8306bfdf 100644 --- a/api/@ohos.hiAppEvent.d.ts +++ b/api/@ohos.hiAppEvent.d.ts @@ -22,6 +22,8 @@ import { AsyncCallback } from './basic'; * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @deprecated since 9 + * @useinstead ohos.hiviewdfx.hiAppEvent */ declare namespace hiAppEvent { /** @@ -72,7 +74,7 @@ declare namespace hiAppEvent { */ namespace Event { /** - * user login event. + * User login event. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -80,7 +82,7 @@ declare namespace hiAppEvent { const USER_LOGIN: string; /** - * user logout event. + * User logout event. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -88,7 +90,7 @@ declare namespace hiAppEvent { const USER_LOGOUT: string; /** - * distributed service event. + * Distributed service event. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -104,7 +106,7 @@ declare namespace hiAppEvent { */ namespace Param { /** - * user id. + * User id. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -112,7 +114,7 @@ declare namespace hiAppEvent { const USER_ID: string; /** - * distributed service name. + * Distributed service name. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -120,7 +122,7 @@ declare namespace hiAppEvent { const DISTRIBUTED_SERVICE_NAME: string; /** - * distributed service instance id. + * Distributed service instance id. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -129,29 +131,28 @@ declare namespace hiAppEvent { } /** - * write application event. + * Write application event. * * @since 7 - * @deprecated since 9 * @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. + * @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. + * 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. + * @param {ConfigOption} config Application event logging configuration item object. + * @return {boolean} Configuration result. */ function configure(config: ConfigOption): boolean; @@ -163,7 +164,7 @@ declare namespace hiAppEvent { */ interface ConfigOption { /** - * configuration item: application event logging switch. + * Configuration item: application event logging switch. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent @@ -171,216 +172,13 @@ declare namespace hiAppEvent { disable?: boolean; /** - * configuration item: event file directory storage quota size. + * Configuration item: event file directory storage quota size. * * @since 7 * @syscap SystemCapability.HiviewDFX.HiAppEvent */ maxStorage?: string; } - - /** - * Definition of written application event information. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface AppEventInfo { - /** - * The domain of the event. - */ - domain: string; - - /** - * The name of the event. - */ - name: string; - - /** - * The type of the event. - */ - eventType: EventType; - - /** - * The params of the event. - */ - params: object; - } - - /** - * write application event. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - * @param {AppEventInfo} info application event information to be written. - * @param {AsyncCallback} [callback] callback function. - * @return {void | Promise} no callback return Promise otherwise return void. - */ - function write(info: AppEventInfo): Promise; - function write(info: AppEventInfo, callback: AsyncCallback): void; - - /** - * Definition of the read event package. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface AppEventPackage { - /** - * The id of the package. - */ - packageId: number; - - /** - * The number of events contained in the package. - */ - row: number; - - /** - * The total size of events contained in the package. - */ - size: number; - - /** - * The events data contained in the package. - */ - data: string[]; - } - - /** - * Definition of event holder object, which is used to read the event data monitored by the watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - class AppEventPackageHolder { - /** - * Constructor for AppEventPackageHolder. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @param {string} watcherName name of the watcher to read. - */ - constructor(watcherName: string); - - /** - * Set the threshold size per read. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @param {number} size threshold size. - */ - setSize(size: number): void; - - /** - * Read the event data monitored by the watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @return {AppEventPackage} the read event package. - */ - takeNext(): AppEventPackage; - } - - /** - * Definition of the condition for triggering callback when the watcher monitors event data. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface TriggerCondition { - /** - * The number of write events that trigger callback. - */ - row?: number; - - /** - * The size of write events that trigger callback. - */ - size?: number; - - /** - * The interval for triggering callback. - */ - timeOut?: number; - } - - /** - * Definition of event filter object, which is used to filter events monitored by the watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface AppEventFilter { - /** - * The name of the event domain to be monitored by the watcher. - */ - domain: string; - - /** - * The types of the events to be monitored by the watcher. - */ - eventTypes?: EventType[]; - } - - /** - * Definition of event watcher object, which is used to monitor written event data. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - */ - interface Watcher { - /** - * The name of watcher. - */ - name: string; - - /** - * The condition for triggering callback. - */ - triggerCondition?: TriggerCondition; - - /** - * The event filters for monitoring events. - */ - appEventFilters?: AppEventFilter[]; - - /** - * The callback function of watcher. - */ - onTrigger?: (curRow: number, curSize:number, holder:AppEventPackageHolder) => void; - } - - /** - * Add event watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - * @param {Watcher} watcher watcher object for monitoring events. - * @return {AppEventPackageHolder} holder object, which is used to read the monitoring data of the watcher. - */ - function addWatcher(watcher: Watcher): AppEventPackageHolder; - - /** - * Remove event watcher. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - * @param {Watcher} watcher watcher object for monitoring events. - */ - function removeWatcher(watcher: Watcher): void; - - /** - * Clear all local logging data of the application. - * - * @since 9 - * @syscap SystemCapability.HiviewDFX.HiAppEvent - * @static - */ - function clearData(): void; } export default hiAppEvent; \ No newline at end of file diff --git a/api/@ohos.hiSysEvent.d.ts b/api/@ohos.hiSysEvent.d.ts index 4e0f662108e457a41a4c1a7c3b13f7c10d54676b..ec97d25b51ccb66fa13b35ea9a5501d8030ad25d 100644 --- a/api/@ohos.hiSysEvent.d.ts +++ b/api/@ohos.hiSysEvent.d.ts @@ -110,6 +110,15 @@ declare namespace hiSysEvent { * @static * @param {SysEventInfo} info system event information to be written. * @param {AsyncCallback} [callback] callback function. + * @throws {BusinessError} 401 - Invalid argument. + * @throws {BusinessError} 11200001 - Invalid event domain. + * @throws {BusinessError} 11200002 - Invalid event name. + * @throws {BusinessError} 11200003 - Abnormal environment. + * @throws {BusinessError} 11200004 - Length of the event is over limit. + * @throws {BusinessError} 11200051 - Invalid event parameter. + * @throws {BusinessError} 11200052 - Size of the event parameter of the string type is over limit. + * @throws {BusinessError} 11200053 - Count of event parameters is over limit. + * @throws {BusinessError} 11200054 - Count of event parameter of the array type is over limit. * @return {void | Promise} no callback return Promise otherwise return void. * @since 9 */ @@ -277,11 +286,10 @@ declare namespace hiSysEvent { * @syscap SystemCapability.HiviewDFX.HiSysEvent * @systemapi hide for inner use * @param {SysEventInfo[]} infos system event information of query result. - * @param {number[]} seqs sequeue of infos. * @return {void} return void. * @since 9 */ - onQuery: (infos: SysEventInfo[], seqs: number[]) => void; + onQuery: (infos: SysEventInfo[]) => void; /** * notify Querier execute query has finished. @@ -303,10 +311,14 @@ declare namespace hiSysEvent { * @systemapi hide for inner use * @permission ohos.permission.READ_DFX_SYSEVENT * @param {Watcher} watcher watch system event - * @return {number} 0 success, 1 fail + * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT. + * @throws {BusinessError} 401 - Invalid argument. + * @throws {BusinessError} 11200101 - Count of watchers is over limit. + * @throws {BusinessError} 11200102 - Count of watch rules is over limit. + * @return {void} return void. * @since 9 */ - function addWatcher(watcher: Watcher): number; + function addWatcher(watcher: Watcher): void; /** * remove watcher @@ -315,10 +327,13 @@ declare namespace hiSysEvent { * @systemapi hide for inner use * @permission ohos.permission.READ_DFX_SYSEVENT * @param {Watcher} watcher watch system event - * @return {number} 0 success, 1 fail + * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT. + * @throws {BusinessError} 401 - Invalid argument. + * @throws {BusinessError} 11200201 - The watcher does not exist. + * @return {void} return void. * @since 9 */ - function removeWatcher(watcher: Watcher): number; + function removeWatcher(watcher: Watcher): void; /** * query system event @@ -329,10 +344,16 @@ declare namespace hiSysEvent { * @param {QueryArg} queryArg common arguments of query system event * @param {QueryRule[]} rules rule of query system event * @param {Querier} querier receive query result - * @return {number} 0 success, 1 fail + * @throws {BusinessError} 201 - Permission denied. An attempt was made to read system event forbidden by permission: ohos.permission.READ_DFX_SYSEVENT. + * @throws {BusinessError} 401 - Invalid argument. + * @throws {BusinessError} 11200301 - Count of query rules is over limit. + * @throws {BusinessError} 11200302 - Invalid query rule. + * @throws {BusinessError} 11200303 - Count of concurrent queriers is over limit. + * @throws {BusinessError} 11200304 - Query frequency is over limit. + * @return {void} return void. * @since 9 */ - function query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): number; + function query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): void; } -export default hiSysEvent; \ No newline at end of file +export default hiSysEvent; diff --git a/api/@ohos.hichecker.d.ts b/api/@ohos.hichecker.d.ts index 678b3b6a3645f2e4c37ca65e617bced415280e8e..55293cb08c16a01a8602167d82288ecec9c7014e 100644 --- a/api/@ohos.hichecker.d.ts +++ b/api/@ohos.hichecker.d.ts @@ -55,6 +55,8 @@ declare namespace hichecker { * add one or more rule. * @param rule * @since 8 + * @deprecated since 9 + * @useinstead ohos.hichecker/hichecker#addCheckRule * @syscap SystemCapability.HiviewDFX.HiChecker */ function addRule(rule: bigint) : void; @@ -63,6 +65,8 @@ declare namespace hichecker { * remove one or more rule. * @param rule * @since 8 + * @deprecated since 9 + * @useinstead ohos.hichecker/hichecker#removeCheckRule * @syscap SystemCapability.HiviewDFX.HiChecker */ function removeRule(rule: bigint) : void; @@ -80,8 +84,38 @@ declare namespace hichecker { * @param rule * @return the result of whether the query rule is added. * @since 8 + * @deprecated since 9 + * @useinstead ohos.hichecker/hichecker#containsCheckRule * @syscap SystemCapability.HiviewDFX.HiChecker */ function contains(rule: bigint) : boolean; + + /** + * Add one or more rule. + * @param rule + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiChecker + * @throws { BusinessError } 401 - the parameter check failed + */ + function addCheckRule(rule: bigint) : void; + + /** + * Remove one or more rule. + * @param rule + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiChecker + * @throws { BusinessError } 401 - the parameter check failed + */ + function removeCheckRule(rule: bigint) : void; + + /** + * Whether the query rule is added + * @param rule + * @return the result of whether the query rule is added. + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiChecker + * @throws { BusinessError } 401 - the parameter check failed + */ + function containsCheckRule(rule: bigint) : boolean; } export default hichecker; \ No newline at end of file diff --git a/api/@ohos.hidebug.d.ts b/api/@ohos.hidebug.d.ts index f5e17b220b60315ddedd8758f66fc86027d715ca..cd2f7bba540dbb11de456f27f9236bc5ee2869e7 100644 --- a/api/@ohos.hidebug.d.ts +++ b/api/@ohos.hidebug.d.ts @@ -89,11 +89,13 @@ declare namespace hidebug { * 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" + * 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 + * @deprecated since 9 + * @useinstead ohos.hidebug/hidebug.startJsCpuProfiling * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug */ function startProfiling(filename : string) : void; @@ -105,6 +107,8 @@ declare namespace hidebug { * @param - * @return - * @since 8 + * @deprecated since 9 + * @useinstead ohos.hidebug/hidebug.stopJsCpuProfiling * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug */ function stopProfiling() : void; @@ -113,24 +117,68 @@ declare namespace hidebug { * 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" + * 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 + * @deprecated since 9 + * @useinstead ohos.hidebug/hidebug.dumpJsHeapData * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug */ function dumpHeapData(filename : string) : void; + /** + * 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. + * + * @param filename Indicates the user-defined file name, excluding the file suffix. + * @throws {BusinessError} 401 - the parameter check failed + * @return - + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function startJsCpuProfiling(filename : string) : void; + + /** + * Stop CPU Profiling. + * It takes effect only when the CPU profiler is turned on + * + * @param - + * @return - + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function stopJsCpuProfiling() : 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. + * + * @param filename Indicates the user-defined file name, excluding the file suffix. + * @throws {BusinessError} 401 - the parameter check failed + * @return - + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug + */ + function dumpJsHeapData(filename : string) : void; + /** * Get a debugging dump of a system service by service id. - * Not for use by third-party applications for permission. + * It need dump permission. * * @param serviceid Indicates the id of the service ability. - * @return - sa dumped file name return. + * @param fd The file descriptor. + * @param args The args list of the system ability dump interface. + * @throws {BusinessError} 401 - the parameter check failed + * @throws {BusinessError} 11400101 - the service id is invalid + * @return - + * @permission ohos.permission.DUMP * @since 9 * @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug */ - function getServiceDump(serviceid : number) : string; + function getServiceDump(serviceid : number, fd : number, args : Array) : void; } export default hidebug; diff --git a/api/@ohos.hiviewdfx.hiAppEvent.d.ts b/api/@ohos.hiviewdfx.hiAppEvent.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d9df9602c09830085844caa2f6a0402c0a9a05c --- /dev/null +++ b/api/@ohos.hiviewdfx.hiAppEvent.d.ts @@ -0,0 +1,388 @@ +/* + * 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 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 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ +declare namespace hiAppEvent { + /** + * Enumerate application event types. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + enum EventType { + /** + * Fault event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + FAULT = 1, + + /** + * Statistic event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + STATISTIC = 2, + + /** + * Security event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + SECURITY = 3, + + /** + * User behavior event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + BEHAVIOR = 4 + } + + /** + * Preset event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + namespace Event { + /** + * User login event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_LOGIN: string; + + /** + * User logout event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_LOGOUT: string; + + /** + * Distributed service event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_START: string; + } + + /** + * Preset param. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + namespace Param { + /** + * User id. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const USER_ID: string; + + /** + * Distributed service name. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_NAME: string; + + /** + * Distributed service instance id. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + const DISTRIBUTED_SERVICE_INSTANCE_ID: string; + } + + /** + * Application event logging configuration interface. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {ConfigOption} config Application event logging configuration item object. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11103001 - Invalid max storage quota value. + */ + function configure(config: ConfigOption): void; + + /** + * Describe the options for the configuration. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface ConfigOption { + /** + * Configuration item: application event logging switch. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + disable?: boolean; + + /** + * Configuration item: event file directory storage quota size. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + maxStorage?: string; + } + + /** + * Definition of written application event information. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface AppEventInfo { + /** + * The domain of the event. + */ + domain: string; + + /** + * The name of the event. + */ + name: string; + + /** + * The type of the event. + */ + eventType: EventType; + + /** + * The params of the event. + */ + params: object; + } + + /** + * Write application event. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {AppEventInfo} info Application event information to be written. + * @param {AsyncCallback} [callback] Callback function. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11100001 - Function is disabled. + * @throws {BusinessError} 11101001 - Invalid event domain. + * @throws {BusinessError} 11101002 - Invalid event name. + * @throws {BusinessError} 11101003 - Invalid number of event parameters. + * @throws {BusinessError} 11101004 - Invalid string length of the event parameter. + * @throws {BusinessError} 11101005 - Invalid event parameter name. + * @throws {BusinessError} 11101006 - Invalid array length of the event parameter. + */ + function write(info: AppEventInfo): Promise; + function write(info: AppEventInfo, callback: AsyncCallback): void; + + /** + * Definition of the read event package. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface AppEventPackage { + /** + * The id of the package. + */ + packageId: number; + + /** + * The number of events contained in the package. + */ + row: number; + + /** + * The total size of events contained in the package. + */ + size: number; + + /** + * The events data contained in the package. + */ + data: string[]; + } + + /** + * Definition of event holder object, which is used to read the event data monitored by the watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + class AppEventPackageHolder { + /** + * Constructor for AppEventPackageHolder. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @param {string} watcherName Name of the watcher to read. + */ + constructor(watcherName: string); + + /** + * Set the threshold size per read. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @param {number} size Threshold size. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11104001 - Invalid size value. + */ + setSize(size: number): void; + + /** + * Read the event data monitored by the watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @return {AppEventPackage} The read event package. + */ + takeNext(): AppEventPackage; + } + + /** + * Definition of the condition for triggering callback when the watcher monitors event data. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface TriggerCondition { + /** + * The number of write events that trigger callback. + */ + row?: number; + + /** + * The size of write events that trigger callback. + */ + size?: number; + + /** + * The interval for triggering callback. + */ + timeOut?: number; + } + + /** + * Definition of event filter object, which is used to filter events monitored by the watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface AppEventFilter { + /** + * The name of the event domain to be monitored by the watcher. + */ + domain: string; + + /** + * The types of the events to be monitored by the watcher. + */ + eventTypes?: EventType[]; + } + + /** + * Definition of event watcher object, which is used to monitor written event data. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + */ + interface Watcher { + /** + * The name of watcher. + */ + name: string; + + /** + * The condition for triggering callback. + */ + triggerCondition?: TriggerCondition; + + /** + * The event filters for monitoring events. + */ + appEventFilters?: AppEventFilter[]; + + /** + * The callback function of watcher. + */ + onTrigger?: (curRow: number, curSize:number, holder:AppEventPackageHolder) => void; + } + + /** + * Add event watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {Watcher} watcher Watcher object for monitoring events. + * @return {AppEventPackageHolder} Holder object, which is used to read the monitoring data of the watcher. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11102001 - Invalid watcher name. + * @throws {BusinessError} 11102002 - Invalid filtering event domain. + * @throws {BusinessError} 11102003 - Invalid row value. + * @throws {BusinessError} 11102004 - Invalid size value. + * @throws {BusinessError} 11102005 - Invalid timeout value. + */ + function addWatcher(watcher: Watcher): AppEventPackageHolder; + + /** + * Remove event watcher. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + * @param {Watcher} watcher Watcher object for monitoring events. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 11102001 - Invalid watcher name. + */ + function removeWatcher(watcher: Watcher): void; + + /** + * Clear all local logging data of the application. + * + * @since 9 + * @syscap SystemCapability.HiviewDFX.HiAppEvent + * @static + */ + function clearData(): void; +} + +export default hiAppEvent; \ No newline at end of file diff --git a/api/@ohos.inputmethod.d.ts b/api/@ohos.inputmethod.d.ts index b551539641e0cf31f9e9d55d2575d4b930b6521b..956e08c7ba8a113f5d4261bd642cf25934ff7aae 100644 --- a/api/@ohos.inputmethod.d.ts +++ b/api/@ohos.inputmethod.d.ts @@ -133,11 +133,8 @@ declare namespace inputMethod { * Input method setting * @since 9 * @return :- - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800007 - settings extension error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function getSetting(): InputMethodSetting; @@ -145,11 +142,8 @@ declare namespace inputMethod { * Input method controller * @since 9 * @return :- - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800006 - input method controller error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function getController(): InputMethodController; @@ -161,10 +155,9 @@ declare namespace inputMethod { * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800007 - settings extension error. * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function switchInputMethod(target: InputMethodProperty, callback: AsyncCallback): void; @@ -176,10 +169,9 @@ declare namespace inputMethod { * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800007 - settings extension error. * @throws {BusinessError} 12800005 - configuration persisting error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function switchInputMethod(target: InputMethodProperty): Promise; @@ -187,11 +179,7 @@ declare namespace inputMethod { * Get current input method * @since 9 * @return The InputMethodProperty object of the current input method - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800007 - settings extension error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function getCurrentInputMethod(): InputMethodProperty; @@ -204,9 +192,8 @@ declare namespace inputMethod { * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800005 - configuration persisting error. - * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function switchCurrentInputMethodSubtype(target: InputMethodSubtype, callback: AsyncCallback): void; @@ -219,9 +206,8 @@ declare namespace inputMethod { * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800005 - configuration persisting error. - * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function switchCurrentInputMethodSubtype(target: InputMethodSubtype): Promise; @@ -229,11 +215,7 @@ declare namespace inputMethod { * Get the current input method subtype * @since 9 * @return The InputMethodSubtype object of the current input method - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800007 - settings extension error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function getCurrentInputMethodSubtype(): InputMethodSubtype; @@ -247,9 +229,8 @@ declare namespace inputMethod { * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800005 - configuration persisting error. - * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype, callback: AsyncCallback): void; @@ -263,9 +244,8 @@ declare namespace inputMethod { * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800005 - configuration persisting error. - * @throws {BusinessError} 12800007 - settings extension error. + * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ function switchCurrentInputMethodAndSubtype(inputMethodProperty: InputMethodProperty, inputMethodSubtype: InputMethodSubtype): Promise; @@ -296,12 +276,10 @@ declare namespace inputMethod { * @since 9 * @param inputMethodProperty Indicates the specified input method * @return :- - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800001 - package manager error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback>): void; @@ -310,12 +288,10 @@ declare namespace inputMethod { * @since 9 * @param inputMethodProperty Indicates the specified input method * @return :- - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800001 - package manager error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ listInputMethodSubtype(inputMethodProperty: InputMethodProperty): Promise>; @@ -323,12 +299,9 @@ declare namespace inputMethod { * List subtype of current input method * @since 9 * @return :- - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800001 - package manager error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ listCurrentInputMethodSubtype(callback: AsyncCallback>): void; @@ -336,12 +309,9 @@ declare namespace inputMethod { * List subtype of current input method * @since 9 * @return :- - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800001 - package manager error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ listCurrentInputMethodSubtype(): Promise>; @@ -352,12 +322,10 @@ declare namespace inputMethod { * If true, collect enabled input methods. * If false, collect disabled input methods. * @return :- - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800001 - package manager error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ getInputMethods(enable: boolean, callback: AsyncCallback>): void; @@ -368,12 +336,10 @@ declare namespace inputMethod { * If true, collect enabled input methods. * If false, collect disabled input methods. * @return :- - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800001 - package manager error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ getInputMethods(enable: boolean): Promise>; @@ -396,13 +362,8 @@ declare namespace inputMethod { * @return :- * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800001 - package manager error. - * @throws {BusinessError} 12800007 - settings extension error. - * @throws {BusinessError} 12800005 - configuration persisting error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ showOptionalInputMethods(callback: AsyncCallback): void; @@ -412,13 +373,8 @@ declare namespace inputMethod { * @return - * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800001 - package manager error. - * @throws {BusinessError} 12800005 - configuration persisting error. - * @throws {BusinessError} 12800007 - settings extension error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ showOptionalInputMethods(): Promise; @@ -446,8 +402,6 @@ declare namespace inputMethod { * @since 9 * @return :- * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -458,8 +412,6 @@ declare namespace inputMethod { * @since 9 * @return :- * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -491,8 +443,7 @@ declare namespace inputMethod { * @return :- * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800003 - input method client error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -504,8 +455,7 @@ declare namespace inputMethod { * @return :- * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800003 - input method client error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -517,8 +467,7 @@ declare namespace inputMethod { * @return :- * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800003 - input method client error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -530,8 +479,7 @@ declare namespace inputMethod { * @return :- * @permission ohos.permission.CONNECT_IME_ABILITY * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. + * @throws {BusinessError} 12800003 - input method client error. * @throws {BusinessError} 12800008 - input method manager service error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -566,14 +514,14 @@ declare namespace inputMethod { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework */ - readonly name?: string; + readonly name: string; /** * The id of input method * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework */ - readonly id?: string; + readonly id: string; /** * The label of input method @@ -601,7 +549,7 @@ declare namespace inputMethod { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework */ - extra?: object; + extra: object; } } diff --git a/api/@ohos.inputmethodengine.d.ts b/api/@ohos.inputmethodengine.d.ts index 9046751db98fad6e1302c64e3a4c694d98a15538..c5426577ba4324fe502f1840fc0308e831d69e63 100644 --- a/api/@ohos.inputmethodengine.d.ts +++ b/api/@ohos.inputmethodengine.d.ts @@ -217,10 +217,6 @@ declare namespace inputMethodEngine { /** * @since 9 * @return InputMethodAbility object of the current input method - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 801 - call unsupported api. - * @throws {BusinessError} 12800002 - input method engine error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ function getInputMethodAbility(): InputMethodAbility; @@ -235,9 +231,6 @@ declare namespace inputMethodEngine { /** * @since 9 * @return KeyboardDelegate object of the current input method - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ function getKeyboardDelegate(): KeyboardDelegate; @@ -255,20 +248,14 @@ declare namespace inputMethodEngine { interface KeyboardController { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. - * @throws {BusinessError} 12800008 - input method manager service error. + * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ hide(callback: AsyncCallback): void; /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. - * @throws {BusinessError} 12800002 - input method engine error. - * @throws {BusinessError} 12800008 - input method manager service error. + * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ hide(): Promise; @@ -531,7 +518,6 @@ declare namespace inputMethodEngine { interface InputClient { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework @@ -540,7 +526,6 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework @@ -549,8 +534,8 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - Input method engine error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -558,8 +543,8 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - Input method engine error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -567,8 +552,8 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - Input method engine error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -576,8 +561,8 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - Input method engine error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -585,8 +570,8 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - Input method engine error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -594,8 +579,8 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. + * @throws {BusinessError} 12800002 - Input method engine error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -603,44 +588,42 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. + * @throws {BusinessError} 12800006 - Input method controller error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ getForward(length: number, callback: AsyncCallback): void; /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. + * @throws {BusinessError} 12800006 - Input method controller error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ getForward(length: number): Promise; /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. + * @throws {BusinessError} 12800006 - Input method controller error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ getBackward(length: number, callback: AsyncCallback): void; /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. + * @throws {BusinessError} 12800006 - Input method controller error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ getBackward(length: number): Promise; /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -648,8 +631,6 @@ declare namespace inputMethodEngine { /** * @since 9 - * @throws {BusinessError} 201 - permissions check fails. - * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. * @syscap SystemCapability.MiscServices.InputMethodFramework */ @@ -662,10 +643,8 @@ declare namespace inputMethodEngine { * @syscap SystemCapability.MiscServices.InputMethodFramework * @param direction Indicates the distance of cursor to be moved. * @return - - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. - * @StageModelOnly */ moveCursor(direction: number, callback: AsyncCallback): void; @@ -676,10 +655,8 @@ declare namespace inputMethodEngine { * @syscap SystemCapability.MiscServices.InputMethodFramework * @param direction Indicates the distance of cursor to be moved. * @return - - * @throws {BusinessError} 201 - permissions check fails. * @throws {BusinessError} 401 - parameter error. * @throws {BusinessError} 12800003 - input method client error. - * @StageModelOnly */ moveCursor(direction: number): Promise; } diff --git a/api/@ohos.inputmethodextensionability.d.ts b/api/@ohos.inputmethodextensionability.d.ts index 9736dd016caeeb13a3e2bbf9d5ec8825ad8cf429..5961f6e39d5590ea01e00bcfc72e6ea3aaa24437 100644 --- a/api/@ohos.inputmethodextensionability.d.ts +++ b/api/@ohos.inputmethodextensionability.d.ts @@ -15,7 +15,6 @@ import rpc from "./@ohos.rpc"; import Want from './@ohos.application.Want'; -import ExtensionAbility from './@ohos.application.ExtensionAbility'; import InputMethodExtensionContext from "./@ohos.inputmethodextensioncontext"; /** @@ -23,14 +22,12 @@ import InputMethodExtensionContext from "./@ohos.inputmethodextensioncontext"; * * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ -export default class InputMethodExtensionAbility extends ExtensionAbility { +export default class InputMethodExtensionAbility { /** * Indicates input method extension ability context. * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ context: InputMethodExtensionContext; @@ -42,7 +39,6 @@ export default class InputMethodExtensionAbility extends ExtensionAbility { * @param want Indicates the want of created service extension. * @return - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly */ onCreate(want: Want): void; @@ -53,59 +49,6 @@ export default class InputMethodExtensionAbility extends ExtensionAbility { * @syscap SystemCapability.MiscServices.InputMethodFramework * @return - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly */ onDestroy(): void; - - /** - * Called back when a input method extension is started. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates the want of service extension to start. - * @param startId Indicates the number of times the service extension has been started. The {@code startId} is - * incremented by 1 every time the service extension is started. For example, if the service extension - * has been started for six times. - * @return - - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly - */ - onRequest(want: Want, startId: number): void; - - /** - * Called back when a input method extension is first connected to an ability. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates connection information about the Service ability. - * @return Returns the proxy of the Service ability. - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly - */ - onConnect(want: Want): rpc.RemoteObject; - - /** - * Called back when all abilities connected to a input method extension are disconnected. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates disconnection information about the service extension. - * @return - - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly - */ - onDisconnect(want: Want): void; - - /** - * Called when a new client attempts to connect to a input method extension after all previous client connections to it - * are disconnected. - * - * @since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @param want Indicates the want of the service extension being connected. - * @return - - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly - */ - onReconnect(want: Want): void; } \ No newline at end of file diff --git a/api/@ohos.inputmethodextensioncontext.d.ts b/api/@ohos.inputmethodextensioncontext.d.ts index c09bd7e0a3264171c298d1168d60a9e2d161c9d8..c6521740a984df5511fd163265a4de68c5c566cb 100644 --- a/api/@ohos.inputmethodextensioncontext.d.ts +++ b/api/@ohos.inputmethodextensioncontext.d.ts @@ -23,45 +23,14 @@ import ExtensionContext from './application/ExtensionContext'; * * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework - * @StageModelOnly */ export default class InputMethodExtensionContext extends ExtensionContext { - /** - * Input method extension uses this method to start a specific ability. - * - * @since 9 - * @deprecated since 9 - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @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; - - /** - * Destroy the input method extension. - * - * @since 9 - * @deprecated since 9 - * @useinstead ohos.inputmethodextensioncontext.InputMethodExtensionContext.destroy - * @syscap SystemCapability.MiscServices.InputMethodFramework - * @return - - * @StageModelOnly - */ - terminateSelf(callback: AsyncCallback): void; - terminateSelf(): Promise; - /** * Destroy the input method extension. * * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @return - - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly */ destroy(callback: AsyncCallback): void; @@ -71,8 +40,6 @@ export default class InputMethodExtensionContext extends ExtensionContext { * @since 9 * @syscap SystemCapability.MiscServices.InputMethodFramework * @return - - * @throws {BusinessError} 401 - parameter error. - * @StageModelOnly */ destroy(): Promise; } \ No newline at end of file diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 0a92de745b8a55f2e485868a1e114147489e161a..d273507577534a032dc99f74c1fbef1480fe4c1a 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -22,12 +22,77 @@ import {ErrorCallback, AsyncCallback, Callback} from './basic'; */ declare namespace audio { /** - * Define local device network id for audio - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - * @systemapi - */ + * Enumerates audio errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioErrors { + /** + * Invalid parameter. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_INVALID_PARAM = 6800101, + /** + * Allocate memory failed. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_NO_MEMORY = 6800102, + /** + * Operation not permit at current state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_ILLEGAL_STATE = 6800103, + /** + * Unsupported option. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_UNSUPPORTED = 6800104, + /** + * Time out. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_TIMEOUT = 6800105, + /** + * Audio specific errors. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_STREAM_LIMIT = 6800201, + /** + * Default error. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + ERROR_SYSTEM = 6800301 + } + + /** + * Define local device network id for audio + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Device + * @systemapi + */ const LOCAL_NETWORK_ID: string; + + /** + * Define default volume group id for audio + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + const DEFAULT_VOLUME_GROUP_ID: number; + + /** + * Define default interrupt group id for audio + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + */ + const DEFAULT_INTERRUPT_GROUP_ID: number; + /** * Obtains an AudioManager instance. * @return AudioManager object. @@ -72,23 +137,25 @@ declare namespace audio { */ function createAudioRenderer(options: AudioRendererOptions): Promise; - /** - * Obtains a TonePlayer instance. This method uses an asynchronous callback to return the renderer instance. - * @param options Tone playing attribute. - * @return Promise used to return the tone player instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback): void; - - /** - * Obtains a TonePlayer instance. This method uses a promise to return the renderer instance. - * @param options Tone playing attribute. - * @return Promise used to return the tone player instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - function createTonePlayer(options: AudioRendererInfo): Promise; + /** + * Obtains a TonePlayer instance. This method uses an asynchronous callback to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + * @systemapi + */ + function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback): void; + + /** + * Obtains a TonePlayer instance. This method uses a promise to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + * @systemapi + */ + function createTonePlayer(options: AudioRendererInfo): Promise; /** * Enumerates the audio states. @@ -325,22 +392,40 @@ declare namespace audio { * Enumerates the active device types. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.CommunicationDeviceType */ - enum ActiveDeviceType { + enum ActiveDeviceType { /** * Speaker. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ SPEAKER = 2, /** * Bluetooth device using the SCO link. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 */ BLUETOOTH_SCO = 7, } + /** + * Enumerates the available device types for communication. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + enum CommunicationDeviceType { + /** + * Speaker. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + SPEAKER = 2 + } + /** * Enumerates ringer modes. * @since 7 @@ -598,7 +683,7 @@ declare namespace audio { * @since 9 * @syscap SystemCapability.Multimedia.Audio.Core */ - STREAM_USAGE_VOICE_ASSISTANT = 3, + STREAM_USAGE_VOICE_ASSISTANT = 3, /** * Notification or ringtone usage. * @since 7 @@ -608,19 +693,19 @@ declare namespace audio { } /** - * Enumerates the focus type. + * Enumerates the audio interrupt request type. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @syscap SystemCapability.Multimedia.Audio.Interrupt * @systemapi */ - enum FocusType { + enum InterruptRequestType { /** - * Recording type. + * Default type to request audio interrupt. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @syscap SystemCapability.Multimedia.Audio.Interrupt * @systemapi */ - FOCUS_TYPE_RECORDING = 0, + INTERRUPT_REQUEST_TYPE_DEFAULT = 0, } /** @@ -681,7 +766,8 @@ declare namespace audio { rendererFlags: number; } - /** Describes audio renderer filter. + /** + * Describes audio renderer filter. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Core * @systemapi @@ -733,19 +819,19 @@ declare namespace audio { /** * Enumerates the interrupt modes. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ enum InterruptMode { /** * Mode that different stream share one interrupt unit. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ SHARE_MODE = 0, /** * Mode that each stream has independent interrupt unit. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Core + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ INDEPENDENT_MODE = 1 } @@ -897,6 +983,7 @@ declare namespace audio { * Enumerates interrupt action types. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ enum InterruptActionType { @@ -904,6 +991,7 @@ declare namespace audio { * Focus gain event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ TYPE_ACTIVATED = 0, @@ -911,6 +999,7 @@ declare namespace audio { * Audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ TYPE_INTERRUPT = 1 } @@ -984,6 +1073,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume */ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback): void; /** @@ -994,6 +1085,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setVolume */ setVolume(volumeType: AudioVolumeType, volume: number): Promise; /** @@ -1002,6 +1095,8 @@ declare namespace audio { * @param callback Callback used to return the volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume */ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1010,6 +1105,8 @@ declare namespace audio { * @return Promise used to return the volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getVolume */ getVolume(volumeType: AudioVolumeType): Promise; /** @@ -1018,6 +1115,8 @@ declare namespace audio { * @param callback Callback used to return the minimum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume */ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1026,6 +1125,8 @@ declare namespace audio { * @return Promise used to return the minimum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMinVolume */ getMinVolume(volumeType: AudioVolumeType): Promise; /** @@ -1034,6 +1135,8 @@ declare namespace audio { * @param callback Callback used to return the maximum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume */ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1042,6 +1145,8 @@ declare namespace audio { * @return Promise used to return the maximum volume. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getMaxVolume */ getMaxVolume(volumeType: AudioVolumeType): Promise; /** @@ -1050,6 +1155,8 @@ declare namespace audio { * @param callback Callback used to return the device list. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices */ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback): void; /** @@ -1058,42 +1165,10 @@ declare namespace audio { * @return Promise used to return the device list. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#getDevices */ getDevices(deviceFlag: DeviceFlag): Promise; - /** - * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. - * @param networkId Device network id - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getVolumeGroups(networkId: string, callback: AsyncCallback): void; - /** - * Get the volume group list for a networkId. This method uses a promise to return the result. - * @param networkId Device network id - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getVolumeGroups(networkId: string): Promise; - /** - * Obtains an AudioGroupManager 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.Volume - * @systemapi - */ - getGroupManager(groupId: number, callback: AsyncCallback): void; - /** - * Obtains an AudioGroupManager instance. This method uses a promise to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi - */ - getGroupManager(groupId: number): Promise; /** * Mutes a stream. This method uses an asynchronous callback to return the result. * @param volumeType Audio stream type. @@ -1101,6 +1176,8 @@ declare namespace audio { * @param callback Callback used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute */ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback): void; /** @@ -1110,6 +1187,8 @@ declare namespace audio { * @return Promise used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#mute */ mute(volumeType: AudioVolumeType, mute: boolean): Promise; /** @@ -1119,6 +1198,8 @@ declare namespace audio { * muted, and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute */ isMute(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1128,6 +1209,8 @@ declare namespace audio { * and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMute */ isMute(volumeType: AudioVolumeType): Promise; /** @@ -1137,6 +1220,8 @@ declare namespace audio { * active, and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive */ isActive(volumeType: AudioVolumeType, callback: AsyncCallback): void; /** @@ -1146,6 +1231,8 @@ declare namespace audio { * and false means the opposite. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Volume + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioStreamManager#isActive */ isActive(volumeType: AudioVolumeType): Promise; /** @@ -1155,6 +1242,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute */ setMicrophoneMute(mute: boolean, callback: AsyncCallback): void; /** @@ -1164,6 +1253,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setMicrophoneMute */ setMicrophoneMute(mute: boolean): Promise; /** @@ -1173,6 +1264,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute */ isMicrophoneMute(callback: AsyncCallback): void; /** @@ -1182,6 +1275,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device * @permission ohos.permission.MICROPHONE + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#isMicrophoneMute */ isMicrophoneMute(): Promise; /** @@ -1191,6 +1286,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode */ setRingerMode(mode: AudioRingMode, callback: AsyncCallback): void; /** @@ -1200,6 +1297,8 @@ declare namespace audio { * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#setRingerMode */ setRingerMode(mode: AudioRingMode): Promise; /** @@ -1207,6 +1306,8 @@ declare namespace audio { * @param callback Callback used to return the ringer mode. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode */ getRingerMode(callback: AsyncCallback): void; /** @@ -1214,6 +1315,8 @@ declare namespace audio { * @return Promise used to return the ringer mode. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Communication + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#getRingerMode */ getRingerMode(): Promise; /** @@ -1260,6 +1363,8 @@ declare namespace audio { * @param callback Callback used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice */ setDeviceActive(deviceType: ActiveDeviceType, active: boolean, callback: AsyncCallback): void; /** @@ -1270,6 +1375,8 @@ declare namespace audio { * @return Promise used to return the result. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#setCommunicationDevice */ setDeviceActive(deviceType: ActiveDeviceType, active: boolean): Promise; /** @@ -1278,6 +1385,8 @@ declare namespace audio { * @param callback Callback used to return the active status of the device. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive */ isDeviceActive(deviceType: ActiveDeviceType, callback: AsyncCallback): void; /** @@ -1286,6 +1395,8 @@ declare namespace audio { * @return Promise used to return the active status of the device. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#isCommunicationDeviceActive */ isDeviceActive(deviceType: ActiveDeviceType): Promise; /** @@ -1294,6 +1405,8 @@ declare namespace audio { * @since 8 * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeManager#event:volumeChange */ on(type: 'volumeChange', callback: Callback): void; /** @@ -1302,6 +1415,8 @@ declare namespace audio { * @since 8 * @syscap SystemCapability.Multimedia.Audio.Communication * @systemapi + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioVolumeGroupManager#event:ringerModeChange */ on(type: 'ringerModeChange', callback: Callback): void; /** @@ -1343,6 +1458,8 @@ declare namespace audio { * @param callback Callback used to obtain the device update details. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange */ on(type: 'deviceChange', callback: Callback): void; @@ -1351,6 +1468,8 @@ declare namespace audio { * @param callback Callback used to obtain the device update details. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Device + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.AudioRoutingManager#event:deviceChange */ off(type: 'deviceChange', callback?: Callback): void; @@ -1376,97 +1495,74 @@ declare namespace audio { off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; /** - * Request independent interrupt event. - * @param focusType The focus type. - * @param callback Callback used to return the result. + * Obtains an AudioVolumeManager instance. + * @return AudioVolumeManager instance. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Volume */ - requestIndependentInterrupt(focusType: FocusType, callback: AsyncCallback): void; + getVolumeManager(): AudioVolumeManager; /** - * Request independent interrupt event. - * @param focusType The focus type. - * @return Promise used to return the result. + * Obtains an AudioStreamManager instance. This method uses an asynchronous callback to return the result. + * @return AudioStreamManager instance. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Core */ - requestIndependentInterrupt(focusType: FocusType): Promise; + getStreamManager(): AudioStreamManager; /** - * Abandon the requested independent interrupt event. - * @param focusType The focus type. - * @param callback Callback used to return the result. + * Obtains an AudioRoutingManager instance. + * @return AudioRoutingManager instance. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi + * @syscap SystemCapability.Multimedia.Audio.Device */ - abandonIndependentInterrupt(focusType: FocusType, callback: AsyncCallback): void; + getRoutingManager(): AudioRoutingManager; + } + /** + * Enumerates audio interrupt request result type. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi + */ + enum InterruptRequestResultType { /** - * Abandon the requested independent interrupt event. - * @param focusType The focus type. - * @return Promise used to return the result. + * Request audio interrupt success * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt * @systemapi */ - abandonIndependentInterrupt(focusType: FocusType): Promise; - + INTERRUPT_REQUEST_GRANT = 0, /** - * Listens for independent 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 independentInterrupt event is supported. - * @param callback Callback invoked for the independent interruption event. + * Request audio interrupt fail, may have higher priority type * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt * @systemapi */ - on(type: 'independentInterrupt', callback: Callback): void; + INTERRUPT_REQUEST_REJECT = 1 + } + /** + * Describes audio interrupt operation results. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi + */ + interface InterruptResult { /** - * Cancels the listening of independent interruption events. - * @param type Type of the event to listen for. Only the independentInterrupt event is supported. - * @param callback Callback invoked for the independent interruption event. + * Interrupt request or abandon result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt * @systemapi */ - off(type: 'independentInterrupt', 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; - + requestResult: InterruptRequestResultType; /** - * Obtains an AudioRoutingManager instance. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. + * Interrupt node as a unit to receive interrupt change event. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - */ - getRoutingManager(callback: AsyncCallback): void; - - /** - * Obtains an AudioRoutingManager instance. This method uses a promise to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Interrupt + * @systemapi */ - getRoutingManager(): Promise; + interruptNode: number; } /** @@ -1491,22 +1587,67 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Device */ getDevices(deviceFlag: DeviceFlag): Promise; + /** * Subscribes to device change events. When a device is connected/disconnected, registered clients will receive * the callback. * @param deviceFlag Audio device flag. * @param callback Callback used to obtain the device update details. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 * @syscap SystemCapability.Multimedia.Audio.Device */ on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback): void; + /** * UnSubscribes to device change events. * @param callback Callback used to obtain the device update details. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 * @syscap SystemCapability.Multimedia.Audio.Device */ off(type: 'deviceChange', callback?: Callback): void; + + /** + * 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 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + setCommunicationDevice(deviceType: CommunicationDeviceType, 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 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + setCommunicationDevice(deviceType: CommunicationDeviceType, 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 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + isCommunicationDeviceActive(deviceType: CommunicationDeviceType, 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 9 + * @syscap SystemCapability.Multimedia.Audio.Communication + */ + isCommunicationDeviceActive(deviceType: CommunicationDeviceType): Promise; + /** * Select the output device. This method uses an asynchronous callback to return the result. * @param outputAudioDevices Audio device description @@ -1525,6 +1666,7 @@ declare namespace audio { * @systemapi */ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise; + /** * Select the output device with desired AudioRenderer. This method uses an asynchronous callback to return the result. * @param filter Filter for AudioRenderer. @@ -1545,6 +1687,7 @@ declare namespace audio { * @systemapi */ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: AudioDeviceDescriptors): Promise; + /** * Select the input device. This method uses an asynchronous callback to return the result. * @param inputAudioDevices Audio device description @@ -1563,13 +1706,6 @@ declare namespace audio { * @systemapi */ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise; - /** - * Listens for system microphone state change events. This method uses a callback to get microphone change events. - * @param callback Callback used to get the system microphone state change event. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device - */ - on(type: 'micStateChange', callback: Callback): void; } /** @@ -1585,7 +1721,6 @@ declare namespace audio { * @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. @@ -1601,7 +1736,6 @@ declare namespace audio { * @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. @@ -1615,6 +1749,8 @@ declare namespace audio { * 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. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ @@ -1622,16 +1758,20 @@ declare namespace audio { /** * UnSubscribes to audio renderer change events. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 * @syscap SystemCapability.Multimedia.Audio.Renderer */ - off(type: "audioRendererChange"); + off(type: "audioRendererChange"): void; /** * 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. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ @@ -1639,19 +1779,92 @@ declare namespace audio { /** * UnSubscribes to audio capturer change events. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 * @syscap SystemCapability.Multimedia.Audio.Capturer */ - off(type: "audioCapturerChange"); + off(type: "audioCapturerChange"): void; + + /** + * 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 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isActive(volumeType: AudioVolumeType): Promise; + } + + /** + * Implements audio volume management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + interface AudioVolumeManager { + /** + * Get the volume group list for a networkId. This method uses an asynchronous callback to return the result. + * @param networkId Distributed deice net work id + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + getVolumeGroupInfos(networkId: string, callback: AsyncCallback): void; + /** + * Get the volume group list for a networkId. This method uses a promise to return the result. + * @param networkId Distributed deice net work id + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @systemapi + */ + getVolumeGroupInfos(networkId: string): Promise; + + /** + * Obtains an AudioVolumeGroupManager instance. This method uses an asynchronous callback to return the result. + * @param groupId volume group id, use LOCAL_VOLUME_GROUP_ID in default + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getVolumeGroupManager(groupId: number, callback: AsyncCallback): void; + /** + * Obtains an AudioVolumeGroupManager instance. This method uses a promise to return the result. + * @param groupId volume group id, use LOCAL_VOLUME_GROUP_ID in default + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getVolumeGroupManager(groupId: number): Promise; + + /** + * Listens for system volume change events. This method uses a callback to get volume change events. + * @param callback Callback used to get the system volume change event. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + on(type: 'volumeChange', callback: Callback): void; } /** * Implements audio volume group management. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume - * @systemapi */ - interface AudioGroupManager { + interface AudioVolumeGroupManager { /** * Sets the volume for a stream. This method uses an asynchronous callback to return the result. * @param volumeType Audio stream type. @@ -1660,6 +1873,7 @@ declare namespace audio { * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback): void; /** @@ -1670,8 +1884,10 @@ declare namespace audio { * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ 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. @@ -1681,13 +1897,14 @@ declare namespace audio { */ 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 9 - * @syscap SystemCapability.Multimedia.Audio.Volume - */ + * 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 9 + * @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. @@ -1704,6 +1921,7 @@ declare namespace audio { * @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. @@ -1720,6 +1938,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume */ getMaxVolume(volumeType: AudioVolumeType): Promise; + /** * Mutes a stream. This method uses an asynchronous callback to return the result. * @param volumeType Audio stream type. @@ -1727,6 +1946,8 @@ declare namespace audio { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback): void; /** @@ -1736,8 +1957,11 @@ declare namespace audio { * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi */ 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. @@ -1756,6 +1980,98 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume */ isMute(volumeType: AudioVolumeType): 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.ACCESS_NOTIFICATION_POLICY + * @systemapi + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + getRingerMode(): Promise; + + /** + * Listens for ringer mode change events. This method uses a callback to get ringer mode changes. + * @param callback Callback used to get the updated ringer mode. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + on(type: 'ringerModeChange', callback: Callback): void; + + /** + * 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.MANAGE_AUDIO_CONFIG + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + * @permission ohos.permission.MANAGE_AUDIO_CONFIG + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + 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 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + isMicrophoneMute(): Promise; + + /** + * Listens for system microphone state change events. This method uses a callback to get microphone change events. + * @param callback Callback used to get the system microphone state change event. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Volume + */ + on(type: 'micStateChange', callback: Callback): void; } /** @@ -1768,13 +2084,14 @@ declare namespace audio { /** * Descript connect type for local device. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Volume */ CONNECT_TYPE_LOCAL = 1, + /** * Descript virtual type for local device. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Device + * @syscap SystemCapability.Multimedia.Audio.Volume */ CONNECT_TYPE_DISTRIBUTED = 2 } @@ -1792,25 +2109,29 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Volume * @systemapi */ - readonly networkId: string; + readonly networkId: string; + /** * Volume group id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ readonly groupId: number; + /** * Volume mapping group id. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ readonly mappingId: number; + /** * Volume group name. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Volume */ readonly groupName: string; + /** * Connect type of device for this group. * @since 9 @@ -2064,6 +2385,8 @@ declare namespace audio { * is interrupted by another application, the callback is invoked to notify the former application. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 + * @useinstead ohos.multimedia.audio.InterruptEvent */ interface InterruptAction { @@ -2072,6 +2395,7 @@ declare namespace audio { * The value TYPE_ACTIVATED means the focus gain event, and TYPE_INTERRUPT means the audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ actionType: InterruptActionType; @@ -2079,6 +2403,7 @@ declare namespace audio { * Type of the audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ type?: InterruptType; @@ -2086,6 +2411,7 @@ declare namespace audio { * Hint for the audio interruption event. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ hint?: InterruptHint; @@ -2094,6 +2420,7 @@ declare namespace audio { * and false means that the focus fails to be gained or released. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ activated?: boolean; } @@ -2102,6 +2429,7 @@ declare namespace audio { * Describes input parameters of audio listening events. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ interface AudioInterrupt { @@ -2109,6 +2437,7 @@ declare namespace audio { * Audio stream usage type. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ streamUsage: StreamUsage; @@ -2116,6 +2445,7 @@ declare namespace audio { * Type of the media interrupted. * @since 7 * @syscap SystemCapability.Multimedia.Audio.Renderer + * @deprecated since 9 */ contentType: ContentType; @@ -2124,6 +2454,7 @@ declare namespace audio { * 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 + * @deprecated since 9 */ pauseWhenDucked: boolean; } @@ -2174,6 +2505,7 @@ declare namespace audio { * @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. @@ -2190,6 +2522,7 @@ declare namespace audio { * @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. @@ -2204,6 +2537,22 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ getStreamInfo(): Promise; + + /** + * Obtains the renderer stream id. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getAudioStreamId(callback: AsyncCallback): void; + /** + * Obtains the renderer stream id. This method uses a promise to return the result. + * @return Promise used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getAudioStreamId(): Promise; + /** * Starts the renderer. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. @@ -2218,6 +2567,7 @@ declare namespace audio { * @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. @@ -2235,6 +2585,7 @@ declare namespace audio { * @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. @@ -2251,6 +2602,7 @@ declare namespace audio { * @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. @@ -2265,6 +2617,7 @@ declare namespace audio { * @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. @@ -2279,6 +2632,7 @@ declare namespace audio { * @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. @@ -2293,6 +2647,7 @@ declare namespace audio { * @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. @@ -2307,6 +2662,7 @@ declare namespace audio { * @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. @@ -2322,6 +2678,7 @@ declare namespace audio { * @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. @@ -2338,6 +2695,7 @@ declare namespace audio { * @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. @@ -2352,12 +2710,13 @@ declare namespace audio { * @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 + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ setInterruptMode(mode: InterruptMode, callback: AsyncCallback): void; /** @@ -2365,17 +2724,38 @@ declare namespace audio { * @param mode The interrupt mode. * @return Promise used to return the result. * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ setInterruptMode(mode: InterruptMode): Promise; + + /** + * Sets the volume for this stream. This method uses an asynchronous callback to return the result. + * @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 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setVolume(volume: number, callback: AsyncCallback): void; + /** + * Sets the volume for a stream. This method uses a promise to return the result. + * @param volume Volume to set. The value range can be obtained by calling getMinVolume and getMaxVolume. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + setVolume(volume: number): 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. + * @throws { BusinessError } 401 - if input parameter type or number mismatch + * @throws { BusinessError } 6800101 - if input parameter value error * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer + * @syscap SystemCapability.Multimedia.Audio.Interrupt */ - on(type: 'interrupt', callback: Callback): void; + on(type: 'audioInterrupt', 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. @@ -2391,6 +2771,7 @@ declare namespace audio { * @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. @@ -2406,6 +2787,7 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: "periodReach"): void; + /** * Subscribes audio state change event callback. * @param callback Callback invoked when state change. @@ -2438,7 +2820,7 @@ declare namespace audio { * @since 9 * @syscap SystemCapability.Multimedia.Audio.Core */ - SOURCE_TYPE_VOICE_RECOGNITION = 1, + SOURCE_TYPE_VOICE_RECOGNITION = 1, /** * Voice communication source type. * @since 8 @@ -2499,6 +2881,7 @@ declare namespace audio { * @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. @@ -2531,6 +2914,21 @@ declare namespace audio { */ getStreamInfo(): Promise; + /** + * Obtains the capturer stream id. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getAudioStreamId(callback: AsyncCallback): void; + /** + * Obtains the capturer stream id. This method uses a promise to return the result. + * @return Promise used to return the stream id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + getAudioStreamId(): Promise; + /** * Starts capturing. This method uses an asynchronous callback to return the result. * @param callback Callback used to return the result. @@ -2668,6 +3066,13 @@ declare namespace audio { */ on(type: "stateChange", callback: Callback): void; } + + /** + * Enumerates tone types for player. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + * @systemapi + */ enum ToneType { /** * Dial tone for key 0. @@ -2837,6 +3242,7 @@ declare namespace audio { * Provides APIs for tone playing. * @since 9 * @syscap SystemCapability.Multimedia.Audio.Tone + * @systemapi */ interface TonePlayer { /** @@ -2903,4 +3309,4 @@ declare namespace audio { } } -export default audio; +export default audio; \ No newline at end of file diff --git a/api/@ohos.multimedia.avsession.d.ts b/api/@ohos.multimedia.avsession.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..060f6b6ed0fced51cf3cc31fc8a9f5a378fdbf2c --- /dev/null +++ b/api/@ohos.multimedia.avsession.d.ts @@ -0,0 +1,996 @@ +/* +* 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 { WantAgent } from '@ohos.wantAgent'; +import KeyEvent from './@ohos.multimodalInput.keyEvent'; +import { ElementName } from './bundleManager/elementName'; +import image from './@ohos.multimedia.image'; +import audio from './@ohos.multimedia.audio'; + +/** + * @name avSession + * @syscap SystemCapability.Multimedia.AVSession.Core + * @import import avsession from '@ohos.multimedia.avsession'; + * @since 9 + */ +declare namespace avSession { + /** + * Create an AVSession instance. An ability can only create one AVSession + * @param context The context of application + * @param tag A user-defined name for this session + * @param type The type of session {@link AVSessionType} + * @param {AsyncCallback} [callback] - callback. + * @returns {void | Promise} no callback returns Promise otherwise returns void + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + function createAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback): void; + function createAVSession(context: Context, tag: string, type: AVSessionType): Promise; + + /** + * Get all avsession descriptors of the system + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @returns The array of {@link AVSessionDescriptor} + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + function getAllSessionDescriptors(callback: AsyncCallback>>): void; + function getAllSessionDescriptors(): Promise>>; + + /** + * Create an avsession controller + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @param sessionId Specifies the sessionId to create the controller. + * If provided 'default', the system will create a default controller, Used to control the system default session + * @returns An instance of {@link AVSessionController} + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + function createController(sessionId: string, callback: AsyncCallback): void; + function createController(sessionId: string): Promise; + + /** + * Cast Audio to the remote devices or cast back local device + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @param audioDevices Specifies the audio devices to cast. + * @param sessionId Specifies the sessionId which to send to remote. + * 'all' means cast all the media audio of this device to remote. + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_REMOTE_CONNECTION_ERR} - remote connection error + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + function castAudio(session: SessionToken | 'all', audioDevices: Array, callback: AsyncCallback): void; + function castAudio(session: SessionToken | 'all', audioDevices: Array): Promise; + + /** + * Session token. Used to judge the legitimacy of the session. + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + interface SessionToken { + /** + * The unique session id of the avsession object + * @since 9 + */ + sessionId: string; + /** + * Process id of session + * @since 9 + */ + pid: number; + /** + * User id + * @since 9 + */ + uid: number; + } + /** + * Register or unregister system session changed callback + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @param type Registration Type, session creation, deletion or top priority session changed + * @param callback Used to returns the descriptor of created or delete session + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + function on(type: 'sessionCreate' | 'sessionDestroy' | 'topSessionChange', callback: (session: AVSessionDescriptor) => void): void; + function off(type: 'sessionCreate' | 'sessionDestroy' | 'topSessionChange', callback?: (session: AVSessionDescriptor) => void): void; + + /** + * Register or unregister Session service death callback, notifying the application to clean up resources. + * @param type Registration Type + * @param callback Used to handle the session service death event. + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} 401 - packagearameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + function on(type: 'sessionServiceDie', callback: () => void): void; + function off(type: 'sessionServiceDie', callback?: () => void): void; + + /** + * Send system media key event.The system automatically selects the recipient. + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @param event The key event to be send + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_COMMAND_INVALID} - command not supported + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + function sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback): void; + function sendSystemAVKeyEvent(event: KeyEvent): Promise; + + /** + * Send system control command.The system automatically selects the recipient. + * @permission ohos.permission.MANAGE_MEDIA_RESOURCES + * @param command The command to be send. See {@link AVControlCommand} + * @throws {BusinessError} 201 - permission denied + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_COMMAND_INVALID} - command not supported + * @throws {BusinessError} {@link #ERR_CODE_MESSAGE_OVERLOAD} - command or event overload + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + function sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback): void; + function sendSystemControlCommand(command: AVControlCommand): Promise; + + /** + * session type. + */ + type AVSessionType = 'audio' | 'video'; + /** + * AVSession object. + * @interface AVSession + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface AVSession { + /** + * unique session Id + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + readonly sessionId: string; + + /** + * Set the metadata of this session. + * In addition to the required properties, users can fill in partially supported properties + * @param data {@link AVMetadata} + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + setAVMetadata(data: AVMetadata, callback: AsyncCallback): void; + setAVMetadata(data: AVMetadata): Promise; + + /** + * Set the playback state of this session. + * @param state {@link AVPlaybackState} + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback): void; + setAVPlaybackState(state: AVPlaybackState): Promise; + + /** + * Set the ability to start the session corresponding to + * @param ability The WantAgent for launch the ability + * @since 9 + * @syscap SystemCapability.Multimedia.AVSession.Core + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + */ + setLaunchAbility(ability: WantAgent, callback: AsyncCallback): void; + setLaunchAbility(ability: WantAgent): Promise; + + /** + * Get the current session's own controller + * @returns The instance of {@link AVSessionController} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + getController(callback: AsyncCallback): void; + getController(): Promise; + + /** + * Get output device information + * @returns The instance of {@link OutputDeviceInfo} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + getOutputDevice(callback: AsyncCallback): void; + getOutputDevice(): Promise; + + /** + * Register or unregister playback command callback. + * As long as it is registered, it means that the ability supports this command. + * If you cancel the callback, you need to call off {@link off} + * When canceling the callback, need to update the supported commands list. + * Each playback command only supports registering one callback, + * and the new callback will replace the previous one. + * @param type Command to register. + * @param callback Used to handle callback commands + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind', callback: () => void): void; + off(type: 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind', callback?: () => void): void; + + /** + * Register or unregister seek command callback + * @param type Registration Type 'seek' + * @param callback Used to handle seek command.The callback provide the seek time(ms) + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'seek', callback: (time: number) => void): void; + off(type: 'seek', callback?: (time: number) => void): void; + + /** + * Register or unregister setSpeed command callback + * @param type Registration Type 'setSpeed' + * @param callback Used to handle setSpeed command.The callback provide the speed value + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'setSpeed', callback: (speed: number) => void): void; + off(type: 'setSpeed', callback?: (speed: number) => void): void; + + /** + * Register or unregister setLoopMode command callback + * @param type Registration Type 'setLoopMode' + * @param callback Used to handle setLoopMode command.The callback provide the {@link LoopMode} + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'setLoopMode', callback: (mode: LoopMode) => void): void; + off(type: 'setLoopMode', callback?: (mode: LoopMode) => void): void; + + /** + * Register or unregister toggle favorite command callback + * @param type Registration Type 'toggleFavorite' + * @param callback Used to handle toggleFavorite command.The callback provide + * the assetId for which the favorite status needs to be switched. + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'toggleFavorite', callback: (assetId: string) => void): void; + off(type: 'toggleFavorite', callback?: (assetId: string) => void): void; + + /** + * Register or unregister media key handling callback + * @param type Registration Type + * @param callback Used to handle key events.The callback provide the KeyEvent + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'handleKeyEvent', callback: (event: KeyEvent) => void): void; + off(type: 'handleKeyEvent', callback?: (event: KeyEvent) => void): void; + + /** + * Register or unregister session output device change callback + * @param type Registration Type + * @param callback Used to handle output device changed. + * The callback provide the new device info {@link OutputDeviceInfo} + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'outputDeviceChange', callback: (device: OutputDeviceInfo) => void): void; + off(type: 'outputDeviceChange', callback?: (device: OutputDeviceInfo) => void): void; + + /** + * Activate the session, indicating that the session can accept control commands + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + activate(callback: AsyncCallback): void; + activate(): Promise; + + /** + * Deactivate the session, indicating that the session not ready to accept control commands + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + deactivate(callback: AsyncCallback): void; + deactivate(): Promise; + + /** + * Destroy this session, the server will clean up the session resources + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + destroy(callback: AsyncCallback): void; + destroy(): Promise; + } + + /** + * The metadata of the current media.Used to set the properties of the current media file + * @interface AVMetadata + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface AVMetadata { + /** + * Unique ID used to represent this media. + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + assetId: string; + /** + * The title of this media, for display in media center. + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + title?: string; + /** + * The artist of this media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + artist?: string; + /** + * The author of this media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + author?: string; + /** + * The album of this media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + album?: string; + /** + * The writer of this media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + writer?: string; + /** + * The composer of this media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + composer?: string; + /** + * The duration of this media, used to automatically calculate playback position + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + duration?: number; + /** + * The image of the media as a {@link PixelMap} or an uri formatted String, + * used to display in media center. + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + mediaImage?: image.PixelMap | string; + /** + * The publishDate of the media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + publishDate?: Date; + /** + * The subtitle of the media, used for display + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + subtitle?: string; + /** + * The discription of the media, used for display + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + description?: string; + /** + * The lyric of the media, it should be in standard lyric format + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + lyric?: string; + /** + * The previous playable media id. + * Used to tell the controller if there is a previous playable media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + previousAssetId?: string; + /** + * The next playable media id. + * Used to tell the controller if there is a next playable media + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + nextAssetId?: string; + } + + /** + * Used to indicate the playback state of the current media. + * If the playback state of the media changes, it needs to be updated synchronously + * @interface AVPlaybackState + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface AVPlaybackState { + /** + * Current playback state. See {@link PlaybackState} + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + state?: PlaybackState; + /** + * Current playback speed + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + speed?: number; + /** + * Current playback position of this media. See {@link PlaybackPosition} + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + position?: PlaybackPosition; + /** + * The current buffered time, the maximum playable position + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + bufferedTime?: number; + /** + * Current playback loop mode. See {@link LoopMode} + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + loopMode?: LoopMode; + /** + * Current Favorite Status + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + isFavorite?: boolean; + } + + /** + * Playback position definition + * @interface PlaybackPosition + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface PlaybackPosition { + /** + * Elapsed time(position) of this media set by the app. + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + elapsedTime: number; + /** + * Record the system time when elapsedTime is set. + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + updateTime: number; + } + /** + * Target Device Information Definition + * @interface OutputDeviceInfo + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface OutputDeviceInfo { + /** + * Whether the remote device + * @since 9 + */ + isRemote: boolean; + /** + * Audio device id.The length of the audioDeviceId array is greater than 1 + * if output to multiple devices at the same time. + * @since 9 + */ + audioDeviceId: Array; + /** + * Device name. The length of the deviceName array is greater than 1 + * if output to multiple devices at the same time. + * @since 9 + */ + deviceName: Array; + } + /** + * Loop Play Mode Definition + * @enum {number} + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + enum LoopMode { + /** + * The default mode is sequential playback + * @since 9 + */ + LOOP_MODE_SEQUENCE = 0, + + /** + * Single loop mode + * @since 9 + */ + LOOP_MODE_SINGLE = 1, + + /** + * List loop mode + * @since 9 + */ + LOOP_MODE_LIST = 2, + + /** + * Shuffle playback mode + * @since 9 + */ + LOOP_MODE_SHUFFLE = 3, + } + + /** + * Definition of current playback state + * @enum {number} + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + enum PlaybackState { + /** + * Initial state. The initial state of media file + * @since 9 + */ + PLAYBACK_STATE_INITIAL = 0, + + /** + * Preparing state. Indicates that the media file is not ready to play, + * the media is loading or buffering + * @since 9 + */ + PLAYBACK_STATE_PREPARE = 1, + + /** + * Playing state. + * @since 9 + */ + PLAYBACK_STATE_PLAY = 2, + + /** + * Paused state. + * @since 9 + */ + PLAYBACK_STATE_PAUSE = 3, + + /** + * Fast forwarding state. + * @since 9 + */ + PLAYBACK_STATE_FAST_FORWARD = 4, + + /** + * Rewinding state. + * @since 9 + */ + PLAYBACK_STATE_REWIND = 5, + + /** + * Stopped state.The server will clear the media playback position and other information. + * @since 9 + */ + PLAYBACK_STATE_STOP = 6, + } + + /** + * The description of the session + * @interface AVSessionDescriptor + * @syscap SystemCapability.Multimedia.AVSession.Manager + * @systemapi + * @since 9 + */ + interface AVSessionDescriptor { + /** + * Unique ID of the session + * @since 9 + */ + sessionId: string; + /** + * Session type, currently supports audio or video + * @since 9 + */ + type: AVSessionType; + /** + * The session tag set by the application + * @since 9 + */ + sessionTag: string; + /** + * The elementName of the ability that created this session. See {@link ElementName} in bundle/elementName.d.ts + * @since 9 + */ + elementName: ElementName; + /** + * Session active state + * @since 9 + */ + isActive: boolean; + /** + * Is it the top priority session + * @since 9 + */ + isTopSession: boolean; + /** + * The current output device information. + * It will be undefined if this is a local session. + * @since 9 + */ + outputDevice: OutputDeviceInfo; + } + + /** + * Session controller,used to control media playback and get media information + * @interface AVSessionController + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface AVSessionController { + /** + * Unique session Id + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + readonly sessionId: string; + /** + * Get the playback status of the current session + * @returns AVPlaybackState {@link AVPlaybackState} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + getAVPlaybackState(callback: AsyncCallback): void; + getAVPlaybackState(): Promise; + + /** + * Get the metadata of the current session + * @returns AVMetadata {@link AVMetadata} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + getAVMetadata(callback: AsyncCallback): void; + getAVMetadata(): Promise; + + /** + * Get output device information + * @returns The instance of {@link OutputDeviceInfo} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + getOutputDevice(callback: AsyncCallback): void; + getOutputDevice(): Promise; + + /** + * Send media key event to this session + * @param event The KeyEvent + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @throws {BusinessError} {@link #ERR_CODE_COMMAND_INVALID} - command not supported + * @throws {BusinessError} {@link #ERR_CODE_SESSION_INACTIVE} - session inactive + * @since 9 + */ + sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback): void; + sendAVKeyEvent(event: KeyEvent): Promise; + + /** + * Get the {@link WantAgent} of this session that can launch the session ability + * @returns WantAgent {@link WantAgent} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + getLaunchAbility(callback: AsyncCallback): void; + getLaunchAbility(): Promise; + + /** + * Get the adjusted playback position. The time automatically calculated by the system + * taking into account factors such as playback status, playback speed, and application update time. + * @returns current playback position in ms.Note that the returns value of each call will be different. + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + getRealPlaybackPositionSync(): number; + + /** + * Check if the current session is active + * @returns the active state + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + isActive(callback: AsyncCallback): void; + isActive(): Promise; + + /** + * Destroy the server controller + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + destroy(callback: AsyncCallback): void; + destroy(): Promise; + + /** + * Get commands supported by the current session + * @returns An array of AVControlCommandType {@link AVControlCommandType} + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + getValidCommands(callback: AsyncCallback>): void; + getValidCommands(): Promise>; + + /** + * Send control commands to this session + * @param command The command to be send. See {@link AVControlCommand} + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @throws {BusinessError} {@link #ERR_CODE_COMMAND_INVALID} - command not supported + * @throws {BusinessError} {@link #ERR_CODE_SESSION_INACTIVE} - session inactive + * @throws {BusinessError} {@link #ERR_CODE_MESSAGE_OVERLOAD} - command or event overload + * @since 9 + */ + sendControlCommand(command: AVControlCommand, callback: AsyncCallback): void; + sendControlCommand(command: AVControlCommand): Promise; + + /** + * Register or unregister metadata changed callback + * @param type 'metadataChange' + * @param filter The properties of {@link AVMetadata} that you cared about + * @param callback The callback used to handle metadata changed event. + * The callback function provides the {@link AVMetadata} parameter. + * It only contains the properties set in the filter. + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + on(type: 'metadataChange', filter: Array | 'all', callback: (data: AVMetadata) => void); + off(type: 'metadataChange', callback?: (data: AVMetadata) => void); + + /** + * Register or unregister playback state changed callback + * @param type 'playbackStateChange' + * @param filter The properties of {@link AVPlaybackState} that you cared about + * @param callback The callback used to handle playback state changed event. + * The callback function provides the {@link AVPlaybackState} parameter. + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + on(type: 'playbackStateChange', filter: Array | 'all', callback: (state: AVPlaybackState) => void); + off(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void); + + /** + * Register or unregister current session destroyed callback + * @param type 'sessionDestroy' + * @param callback The callback used to handle current session destroyed event. + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + on(type: 'sessionDestroy', callback: () => void); + off(type: 'sessionDestroy', callback?: () => void); + + /** + * Register or unregister the active state of this session changed callback + * @param type 'activeStateChange' + * @param callback The callback used to handle the active state of this session changed event. + * The callback function provides the changed session state. + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + on(type: 'activeStateChange', callback: (isActive: boolean) => void); + off(type: 'activeStateChange', callback?: (isActive: boolean) => void); + + /** + * Register or unregister the valid commands of the session changed callback + * @param type 'validCommandChange' + * @param callback The callback used to handle the changes. + * The callback function provides an array of AVControlCommandType. + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @since 9 + */ + on(type: 'validCommandChange', callback: (commands: Array) => void); + off(type: 'validCommandChange', callback?: (commands: Array) => void); + + /** + * Register or unregister session output device change callback + * @param type Registration Type + * @param callback Used to handle output device changed. + * The callback provide the new device info {@link OutputDeviceInfo} + * @throws {BusinessError} 401 - parameter check failed + * @throws {BusinessError} {@link #ERR_CODE_SERVICE_EXCEPTION} - server exception + * @throws {BusinessError} {@link #ERR_CODE_CONTROLLER_NOT_EXIST} - controller does not exist + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + on(type: 'outputDeviceChange', callback: (device: OutputDeviceInfo) => void): void; + off(type: 'outputDeviceChange', callback?: (device: OutputDeviceInfo) => void): void; + } + + /** + * The type of control command + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + type AVControlCommandType = 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind' | + 'seek' | 'setSpeed' | 'setLoopMode' | 'toggleFavorite'; + + /** + * The definition of command to be sent to the session + * @interface AVControlCommand + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + interface AVControlCommand { + /** + * The command value {@link AVControlCommandType} + * @since 9 + */ + command: AVControlCommandType; + /** + * parameter of the command. Whether this command requires parameters, see {@link AVSessionCommand} + * seek command requires a number parameter + * setSpeed command requires a number parameter + * setLoopMode command requires a {@link LoopMode} parameter. + * toggleFavorite command requires assetId {@link AVMetadata.assetId} parameter + * other commands need no parameter + * @since 9 + */ + parameter?: LoopMode | string | number; + } + + /** + * Enumerates ErrorCode types, returns in BusinessError.code. + * @enum {number} + * @syscap SystemCapability.Multimedia.AVSession.Core + * @since 9 + */ + enum AVSessionErrorCode { + /** + * Server exception + * @since 9 + */ + ERR_CODE_SERVICE_EXCEPTION = 6600101, + + /** + * The session does not exist + * @since 9 + */ + ERR_CODE_SESSION_NOT_EXIST = 6600102, + + /** + * The controller does not exist + * @since 9 + */ + ERR_CODE_CONTROLLER_NOT_EXIST = 6600103, + + /** + * Remote connection error + * @since 9 + */ + ERR_CODE_REMOTE_CONNECTION_ERR = 6600104, + + /** + * Command not supported + * @since 9 + */ + ERR_CODE_COMMAND_INVALID = 6600105, + + /** + * Session inactive + * @since 9 + */ + ERR_CODE_SESSION_INACTIVE = 6600106, + + /** + * Command or event overload + * @since 9 + */ + ERR_CODE_MESSAGE_OVERLOAD = 6600107, + } +} + +export default avSession; diff --git a/api/@ohos.multimedia.camera.d.ts b/api/@ohos.multimedia.camera.d.ts index 18c9ad1114e260e8815a209e9f199aff24ac1b89..596e921301c373de1fc14ad12fb1654080dfac8d 100644 --- a/api/@ohos.multimedia.camera.d.ts +++ b/api/@ohos.multimedia.camera.d.ts @@ -59,19 +59,105 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_STATUS_DISAPPEAR, + CAMERA_STATUS_DISAPPEAR = 1, /** * Available status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_STATUS_AVAILABLE, + CAMERA_STATUS_AVAILABLE = 2, /** * Unavailable status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_STATUS_UNAVAILABLE + CAMERA_STATUS_UNAVAILABLE = 3 + } + + /** + * Profile for camera streams. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Profile { + /** + * Camera format. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly format: CameraFormat; + /** + * Picture size. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly size: Size; + } + + /** + * Frame rate range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface FrameRateRange { + /** + * Min frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly min: number; + /** + * Max frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly max: number; + } + + /** + * Video profile. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface VideoProfile extends Profile { + /** + * Frame rate in unit fps (frames per second). + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly frameRateRange: FrameRateRange; + } + + /** + * Camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraOutputCapability { + /** + * Preview profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly previewProfiles: Array; + /** + * Photo profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly photoProfiles: Array; + /** + * Video profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly videoProfiles: Array; + /** + * All the supported metadata Object Types. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly supportedMetadataObjectTypes: Array; } /** @@ -81,40 +167,84 @@ declare namespace camera { */ interface CameraManager { /** - * Gets all camera descriptions. + * Gets supported camera descriptions. * @param callback Callback used to return the array of supported cameras. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameras(callback: AsyncCallback>): void; + getSupportedCameras(callback: AsyncCallback>): void; /** - * Gets all camera descriptions. + * Gets supported camera descriptions. * @return Promise used to return an array of supported cameras. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameras(): Promise>; + getSupportedCameras(): Promise>; + + /** + * Gets supported output capability for specific camera. + * @param camera Camera device. + * @param callback Callback used to return the camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void; + + /** + * Gets supported output capability for specific camera. + * @param camera Camera device. + * @return Promise used to return the camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getSupportedOutputCapability(camera: CameraDevice): Promise; + + /** + * Determine whether camera is muted. + * @return Is camera muted. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isCameraMuted(): boolean; + + /** + * Determine whether camera mute is supported. + * @return Is camera mute supported. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + isCameraMuteSupported(): boolean; /** - * Creates a CameraInput instance by camera id. - * @param cameraId Camera ID used to create the instance. + * Mute camera. + * @param mute Mute camera if TRUE, otherwise unmute camera. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + muteCamera(mute: boolean): void; + + /** + * Creates a CameraInput instance by camera. + * @param camera Camera device 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; + createCameraInput(camera: CameraDevice, callback: AsyncCallback): void; /** - * Creates a CameraInput instance by camera id. - * @param cameraId Camera ID used to create the instance. + * Creates a CameraInput instance by camera. + * @param camera Camera device 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; + createCameraInput(camera: CameraDevice): Promise; /** * Creates a CameraInput instance by camera position and type. @@ -138,6 +268,100 @@ declare namespace camera { */ createCameraInput(position: CameraPosition, type: CameraType): Promise; + /** + * Creates a PreviewOutput instance. + * @param profile Preview output profile. + * @param surfaceId Surface object id used in camera photo output. + * @param callback Callback used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; + + /** + * Creates a PreviewOutput instance. + * @param profile Preview output profile. + * @param surfaceId Surface object id used in camera photo output. + * @return Promise used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createPreviewOutput(profile: Profile, surfaceId: string): Promise; + + /** + * Creates a PhotoOutput instance. + * @param profile Photo output profile. + * @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 + */ + createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; + + /** + * Creates a PhotoOutput instance. + * @param profile Photo output profile. + * @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 + */ + createPhotoOutput(profile: Profile, surfaceId: string): Promise; + + /** + * Creates a VideoOutput instance. + * @param profile Video profile. + * @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 + */ + createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void; + + /** + * Creates a VideoOutput instance. + * @param profile Video profile. + * @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 + */ + createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; + + /** + * Creates a MetadataOutput instance. + * @param metadataObjectTypes Array of MetadataObjectType. + * @param callback Callback used to return the MetadataOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void; + + /** + * Creates a MetadataOutput instance. + * @param metadataObjectTypes Array of MetadataObjectType. + * @return Promise used to return the MetadataOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createMetadataOutput(metadataObjectTypes: Array): Promise; + + /** + * Gets a CaptureSession instance. + * @param callback Callback used to return the CaptureSession instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createCaptureSession(callback: AsyncCallback): void; + + /** + * Gets a CaptureSession instance. + * @return Promise used to return the CaptureSession instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createCaptureSession(): Promise; + /** * Subscribes camera status change event callback. * @param type Event type. @@ -146,6 +370,16 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ on(type: 'cameraStatus', callback: AsyncCallback): void; + + /** + * Subscribes camera mute change event callback. + * @param type Event type. + * @param callback Callback used to get the camera mute change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + on(type: 'cameraMute', callback: AsyncCallback): void; } /** @@ -159,7 +393,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - camera: Camera; + camera: CameraDevice; /** * Current camera status. * @since 9 @@ -185,13 +419,13 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_POSITION_BACK, + CAMERA_POSITION_BACK = 1, /** * Front position. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_POSITION_FRONT + CAMERA_POSITION_FRONT = 2 } /** @@ -212,28 +446,28 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_WIDE_ANGLE, + CAMERA_TYPE_WIDE_ANGLE = 1, /** * Ultra wide camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_ULTRA_WIDE, + CAMERA_TYPE_ULTRA_WIDE = 2, /** * Telephoto camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_TELEPHOTO, + CAMERA_TYPE_TELEPHOTO = 3, /** * True depth camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_TRUE_DEPTH + CAMERA_TYPE_TRUE_DEPTH = 4 } /** @@ -254,22 +488,22 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_CONNECTION_USB_PLUGIN, + CAMERA_CONNECTION_USB_PLUGIN = 1, /** * Remote camera * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_CONNECTION_REMOTE + CAMERA_CONNECTION_REMOTE = 2 } /** - * Camera object. + * Camera device object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface Camera { + interface CameraDevice { /** * Camera id attribute. * @since 9 @@ -317,284 +551,217 @@ declare namespace camera { } /** - * Camera input object. + * Point parameter. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface CameraInput { + interface Point { /** - * Gets camera id. - * @param callback Callback used to return the camera ID. + * x co-ordinate * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameraId(callback: AsyncCallback): void; - + x: number; /** - * Gets camera id. - * @return Promise used to return the camera ID. + * y co-ordinate * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameraId(): Promise; + y: number; + } + /** + * Camera input object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraInput { /** - * Check if device has flash light. - * @param callback Callback used to return the flash light support status. + * Open camera. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - hasFlash(callback: AsyncCallback): void; + open(callback: AsyncCallback): void; /** - * Check if device has flash light. - * @return Promise used to return the flash light support status. + * Open camera. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - hasFlash(): Promise; + open(): Promise; /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode. - * @param callback Callback used to return the flash light support status. + * Close camera. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + close(callback: AsyncCallback): void; /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode - * @return Promise used to return flash mode support status. + * Close camera. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isFlashModeSupported(flashMode: FlashMode): Promise; + close(): Promise; /** - * Gets current flash mode. - * @param callback Callback used to return the current flash mode. + * Releases instance. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFlashMode(callback: AsyncCallback): void; + release(callback: AsyncCallback): void; /** - * Gets current flash mode. - * @return Promise used to return the flash mode. + * Releases instance. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFlashMode(): Promise; + release(): Promise; /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @param callback Callback used to return the result. + * Subscribes error event callback. + * @param type Event type. + * @param camera Camera device. + * @param callback Callback used to get the camera input errors. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; + } + /** + * Enum for CameraInput error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraInputErrorCode { /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @return Promise used to return the result. + * Unknown error. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - setFlashMode(flashMode: FlashMode): Promise; - + ERROR_UNKNOWN = -1, /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @param callback Callback used to return the device focus support status. + * No permission. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - + ERROR_NO_PERMISSION = 0, /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @return Promise used to return the focus mode support status. + * Camera device preempted. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - isFocusModeSupported(afMode: FocusMode): Promise; - + ERROR_DEVICE_PREEMPTED = 1, /** - * Gets current focus mode. - * @param callback Callback used to return the current focus mode. + * Camera device disconnected. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - getFocusMode(callback: AsyncCallback): void; - + ERROR_DEVICE_DISCONNECTED = 2, /** - * Gets current focus mode. - * @return Promise used to return the focus mode. + * Camera device in use. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - getFocusMode(): Promise; - + ERROR_DEVICE_IN_USE = 3, /** - * Sets focus mode. - * @param afMode Target focus mode. - * @param callback Callback used to return the result. + * Driver error. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; + ERROR_DRIVER_ERROR = 4, + } + + /** + * Camera input error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraInputError extends Error { + code: CameraInputErrorCode; + } + /** + * Enum for camera format type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraFormat { /** - * Sets focus mode. - * @param afMode Target focus mode. - * @return Promise used to return the result. + * RGBA 8888 Format. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setFocusMode(afMode: FocusMode): Promise; + CAMERA_FORMAT_RGBA_8888 = 3, /** - * Gets all supported zoom ratio range. - * @param callback Callback used to return the zoom ratio range. + * YUV 420 Format. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getZoomRatioRange(callback: AsyncCallback>): void; + CAMERA_FORMAT_YUV_420_SP = 1003, /** - * Gets all supported zoom ratio range. - * @return Promise used to return the zoom ratio range. + * JPEG Format. * @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; + CAMERA_FORMAT_JPEG = 2000 + } + /** + * Enum for flash mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum FlashMode { /** - * Releases instance. - * @param callback Callback used to return the result. + * Close mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; - + FLASH_MODE_CLOSE = 0, /** - * Releases instance. - * @return Promise used to return the result. + * Open mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; - + FLASH_MODE_OPEN = 1, /** - * Subscribes focus status change event callback. - * @param type Event type. - * @param callback Callback used to get the focus state change. + * Auto mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'focusStateChange', callback: AsyncCallback): void; - + FLASH_MODE_AUTO = 2, /** - * Subscribes error event callback. - * @param type Event type. - * @param callback Callback used to get the camera input errors. + * Always open mode. * @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 + FLASH_MODE_ALWAYS_OPEN = 3 } /** - * Camera input error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CameraInputError extends Error { - code: CameraInputErrorCode; - } - - /** - * Enum for flash mode. + * Enum for exposure mode. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - enum FlashMode { - /** - * Close mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - FLASH_MODE_CLOSE = 0, + enum ExposureMode { /** - * Open mode. + * Lock exposure mode. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - FLASH_MODE_OPEN, + EXPOSURE_MODE_LOCKED = 0, /** - * Auto mode. + * Auto exposure mode. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - FLASH_MODE_AUTO, - /** - * Always open mode. + EXPOSURE_MODE_AUTO = 1, + /** + * Continuous automatic exposure. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - FLASH_MODE_ALWAYS_OPEN + EXPOSURE_MODE_CONTINUOUS_AUTO = 2 } /** @@ -614,19 +781,19 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - FOCUS_MODE_CONTINUOUS_AUTO, + FOCUS_MODE_CONTINUOUS_AUTO = 1, /** * Auto mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - FOCUS_MODE_AUTO, + FOCUS_MODE_AUTO = 2, /** * Locked mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - FOCUS_MODE_LOCKED + FOCUS_MODE_LOCKED = 3 } /** @@ -646,32 +813,52 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - FOCUS_STATE_FOCUSED, + FOCUS_STATE_FOCUSED = 1, /** * Unfocused state. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - FOCUS_STATE_UNFOCUSED + FOCUS_STATE_UNFOCUSED = 2 } /** - * 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. + * Enum for video stabilization mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - function createCaptureSession(context: Context): Promise; + enum VideoStabilizationMode { + /** + * Turn off video stablization. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + OFF = 0, + /** + * LOW mode provides basic stabilization effect. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + LOW = 1, + /** + * MIDDLE mode means algorithms can achieve better effects than LOW mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + MIDDLE = 2, + /** + * HIGH mode means algorithms can achieve better effects than MIDDLE mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + HIGH = 3, + /** + * Camera HDF can select mode automatically. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + AUTO = 4 + } /** * Capture session object. @@ -730,178 +917,523 @@ declare namespace camera { addInput(cameraInput: CameraInput): Promise; /** - * Adds a camera preview output. - * @param previewOutput Target camera preview output to add. + * 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 */ - addOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; /** - * Adds a camera preview output. - * @param previewOutput Target camera preview output to add. + * 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 */ - addOutput(previewOutput: PreviewOutput): Promise; + removeInput(cameraInput: CameraInput): Promise; /** - * Adds a camera photo output. - * @param photoOutput Target camera photo output to add. + * Adds a camera output. + * @param cameraOutput Target camera output to add. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; /** - * Adds a camera photo output. - * @param photoOutput Target camera photo output to add. + * Adds a camera output. + * @param cameraOutput Target camera output to add. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(photoOutput: PhotoOutput): Promise; + addOutput(cameraOutput: CameraOutput): Promise; /** - * Adds a camera video output. - * @param videoOutput Target camera video output to add. + * Removes a camera output. + * @param previewOutput Target camera output to remove. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; /** - * Adds a camera video output. - * @param videoOutput Target camera video output to add. + * Removes a camera output. + * @param previewOutput Target camera output to remove. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(videoOutput: VideoOutput): Promise; + removeOutput(cameraOutput: CameraOutput): Promise; /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. + * Starts capture session. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; + start(callback: AsyncCallback): void; /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. + * Starts capture session. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeInput(cameraInput: CameraInput): Promise; + start(): Promise; /** - * Removes a camera preview output. - * @param previewOutput Target camera preview output to remove. + * Stops capture session. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + stop(callback: AsyncCallback): void; /** - * Removes a camera preview output. - * @param previewOutput Target camera preview output to remove. + * Stops capture session. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(previewOutput: PreviewOutput): Promise; + stop(): Promise; /** - * Removes a camera photo output. - * @param photoOutput Target camera photo output to remove. + * Release capture session instance. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + release(callback: AsyncCallback): void; /** - * Removes a camera photo output. - * @param photoOutput Target camera photo output to remove. + * Release capture session instance. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(photoOutput: PhotoOutput): Promise; + release(): 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; /** - * Removes a camera video output. - * @param videoOutput Target camera video output to remove. + * Sets flash mode. + * @param flashMode Target flash mode. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; /** - * Removes a camera video output. - * @param videoOutput Target camera video output to remove. + * Sets flash mode. + * @param flashMode Target flash mode. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(videoOutput: VideoOutput): Promise; + setFlashMode(flashMode: FlashMode): Promise; + + /** + * Checks whether a specified exposure mode is supported. + * @param aeMode Exposure mode. + * @param callback Callback used to return the exposure mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void; /** - * Starts capture session. + * Checks whether a specified exposure mode is supported. + * @param aeMode Exposure mode + * @return Promise used to return exposure mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isExposureModeSupported(aeMode: ExposureMode): Promise; + + /** + * Gets current exposure mode. + * @param callback Callback used to return the current exposure mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureMode(callback: AsyncCallback): void; + + /** + * Gets current exposure mode. + * @return Promise used to return the current exposure mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureMode(): Promise; + + /** + * Sets exposure mode. + * @param aeMode Exposure mode * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - start(callback: AsyncCallback): void; + setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void; + + /** + * Sets Exposure mode. + * @param aeMode Exposure mode + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setExposureMode(aeMode: ExposureMode): Promise; /** - * Starts capture session. + * Gets current metering point. + * @param callback Callback used to return the current metering point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getMeteringPoint(callback: AsyncCallback): void; + + /** + * Gets current metering point. + * @return Promise used to return the current metering point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getMeteringPoint(): Promise; + + /** + * Set the center point of the metering area. + * @param point Metering point + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setMeteringPoint(point: Point, callback: AsyncCallback): void; + + /** + * Set the center point of the metering area. + * @param point metering point + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setMeteringPoint(point: Point): Promise; + + /** + * Query the exposure compensation range. + * @param callback Callback used to return the array of compenstation range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureBiasRange(callback: AsyncCallback>): void; + + /** + * Query the exposure compensation range. + * @return Promise used to return the array of compenstation range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureBiasRange(): Promise>; + + /** + * Set exposure compensation. + * @param exposureBias Exposure compensation + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setExposureBias(exposureBias: number, callback: AsyncCallback): void; + + /** + * Set exposure compensation. + * @param exposureBias Exposure compensation * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - start(): Promise; + setExposureBias(exposureBias: number): Promise; /** - * Stops capture session. + * Query the exposure value. + * @param callback Callback used to return the exposure value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureValue(callback: AsyncCallback): void; + + /** + * Query the exposure value. + * @return Promise used to return the exposure value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureValue(): 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 */ - stop(callback: AsyncCallback): void; + setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; /** - * Stops capture session. + * Sets focus mode. + * @param afMode Target focus mode. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - stop(): Promise; + setFocusMode(afMode: FocusMode): Promise; /** - * Release capture session instance. + * Sets focus point. + * @param point Target focus point. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; + setFocusPoint(point: Point, callback: AsyncCallback): void; /** - * Release capture session instance. + * Sets focus point. + * @param afMode Target focus point. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; + setFocusPoint(point: Point): Promise; + + /** + * Gets current focus point. + * @param callback Callback used to return the current focus point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocusPoint(callback: AsyncCallback): void; + + /** + * Gets current focus point. + * @return Promise used to return the current focus point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocusPoint(): Promise; + + /** + * Gets current focal length. + * @param callback Callback used to return the current focal point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocalLength(callback: AsyncCallback): void; + + /** + * Gets current focal length. + * @return Promise used to return the current focal point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocalLength(): 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; + + /** + * Check whether the specified video stabilization mode is supported. + * @param vsMode Video Stabilization mode. + * @param callback Callback used to return if video stablization mode is supported. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void; + + /** + * Check whether the specified video stabilization mode is supported. + * @param callback Callback used to return if video stablization mode is supported. + * @return Promise used to return flash mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise; + + /** + * Query the video stabilization mode currently in use. + * @param callback Callback used to return the current video stabilization mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getActiveVideoStabilizationMode(callback: AsyncCallback): void; + + /** + * Query the video stabilization mode currently in use. + * @return Promise used to return the current video stabilization mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getActiveVideoStabilizationMode(): Promise; + + /** + * Set video stabilization mode. + * @param mode video stabilization mode to set. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void; + + /** + * Set video stabilization mode. + * @param mode video stabilization mode to set. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setVideoStabilizationMode(mode: VideoStabilizationMode): 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. @@ -919,7 +1451,21 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum CaptureSessionErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, + /** + * Insufficient resources. + * @since 9 + */ + ERROR_INSUFFICIENT_RESOURCES = 0, + /** + * Timeout error. + * @since 9 + */ + ERROR_TIMEOUT = 1, } /** @@ -932,44 +1478,65 @@ declare namespace camera { } /** - * Creates a PreviewOutput instance. - * @param surfaceId Surface object id used in camera preview output. - * @param callback Callback used to return the PreviewOutput instance. + * Camera output object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - function createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; + interface CameraOutput { + /** + * Release output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(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; + /** + * Release output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + } /** * Preview output object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface PreviewOutput { + interface PreviewOutput extends CameraOutput { /** - * Release output instance. + * Start output instance. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; + start(callback: AsyncCallback): void; /** - * Release output instance. + * Start output instance. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; + start(): Promise; + + /** + * Stop output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(callback: AsyncCallback): void; + + /** + * Stop output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(): Promise; /** * Subscribes frame start event callback. @@ -1005,7 +1572,11 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum PreviewOutputErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, } /** @@ -1017,24 +1588,6 @@ declare namespace camera { 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 @@ -1070,6 +1623,26 @@ declare namespace camera { ROTATION_270 = 270 } + interface Location { + /** + * Latitude. + * @since 9 + */ + latitude: number; + + /** + * Longitude. + * @since 9 + */ + longitude: number; + + /** + * Altitude. + * @since 9 + */ + altitude: number; + } + /** * Enumerates the image quality levels. * @since 9 @@ -1088,14 +1661,14 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - QUALITY_LEVEL_MEDIUM, + QUALITY_LEVEL_MEDIUM = 1, /** * Low image quality. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - QUALITY_LEVEL_LOW + QUALITY_LEVEL_LOW = 2 } /** @@ -1109,12 +1682,27 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ quality?: QualityLevel; + /** * Photo rotation. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ rotation?: ImageRotation; + + /** + * Photo location. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + location?: Location; + + /** + * Set the mirror photo function switch, default to false. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + mirror?: boolean; } /** @@ -1122,7 +1710,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface PhotoOutput { + interface PhotoOutput extends CameraOutput { /** * Start capture output. * @param callback Callback used to return the result. @@ -1150,20 +1738,20 @@ declare namespace camera { capture(setting?: PhotoCaptureSetting): Promise; /** - * Release output instance. - * @param callback Callback used to return the result. + * Check whether to support mirror photo. + * @param callback Callback used to return the mirror support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; + isMirrorSupported(callback: AsyncCallback): void; /** - * Release output instance. - * @return Promise used to return the result. + * Check whether to support mirror photo. + * @return Promise used to return the mirror support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; + isMirrorSupported(): Promise; /** * Subscribes capture start event callback. @@ -1248,7 +1836,26 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum PhotoOutputErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, + /** + * Driver error. + * @since 9 + */ + ERROR_DRIVER_ERROR = 0, + /** + * Insufficient resources. + * @since 9 + */ + ERROR_INSUFFICIENT_RESOURCES = 1, + /** + * Timeout error. + * @since 9 + */ + ERROR_TIMEOUT = 2 } /** @@ -1260,30 +1867,12 @@ declare namespace camera { 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 { + interface VideoOutput extends CameraOutput { /** * Start video output. * @param callback Callback used to return the result. @@ -1292,7 +1881,7 @@ declare namespace camera { */ start(callback: AsyncCallback): void; - /** + /** * Start video output. * @return Promise used to return the result. * @since 9 @@ -1316,22 +1905,6 @@ declare namespace camera { */ 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. @@ -1366,7 +1939,16 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum VideoOutputErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, + /** + * Driver error. + * @since 9 + */ + ERROR_DRIVER_ERROR = 0 } /** @@ -1377,6 +1959,196 @@ declare namespace camera { interface VideoOutputError extends Error { code: VideoOutputErrorCode; } + + /** + * Metadata object type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum MetadataObjectType { + FACE_DETECTION = 0 + } + + /** + * Rectangle definition. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Rect { + /** + * X coordinator of top left point. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + topLeftX: number; + /** + * Y coordinator of top left point. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + topLeftY: number; + /** + * Width of this rectangle. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + width: number; + /** + * Height of this rectangle. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + height: number; + } + + /** + * Metadata object basis. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataObject { + /** + * Get current metadata object type. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getType(callback: AsyncCallback): void; + + /** + * Get current metadata object type. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getType(): Promise; + + /** + * Get current metadata object timestamp in milliseconds. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getTimestamp(callback: AsyncCallback): void; + + /** + * Get current metadata object timestamp in milliseconds. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getTimestamp(): Promise; + + /** + * Get the axis-aligned bounding box of detected metadata object. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getBoundingBox(callback: AsyncCallback): void; + + /** + * Get the axis-aligned bounding box of detected metadata object. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getBoundingBox(): Promise; + } + + /** + * Metadata face object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataFaceObject extends MetadataObject { + } + + /** + * Metadata Output object + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataOutput extends CameraOutput { + /** + * Start output metadata + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(callback: AsyncCallback): void; + + /** + * Start output metadata + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(): Promise; + + /** + * Stop output metadata + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(callback: AsyncCallback): void; + + /** + * Stop output metadata + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(): Promise; + + /** + * Subscribes to metadata objects available event callback. + * @param type Event type. + * @param callback Callback used to get the available metadata objects. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'metadataObjectsAvailable', 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 metadata output error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum MetadataOutputErrorCode { + /** + * Unknown errors. + * @since 9 + */ + ERROR_UNKNOWN = -1, + /** + * Insufficient resources. + * @since 9 + */ + ERROR_INSUFFICIENT_RESOURCES = 0 + } + + /** + * Metadata output error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataOutputError extends Error { + code: MetadataOutputErrorCode; + } } export default camera; diff --git a/api/@ohos.multimedia.media.d.ts b/api/@ohos.multimedia.media.d.ts index 9d9547f1801a8494716303b86f4e5f98e9f59299..c6ab1c28358f408fe9face76e5ee6d397e059560 100644 --- a/api/@ohos.multimedia.media.d.ts +++ b/api/@ohos.multimedia.media.d.ts @@ -63,6 +63,8 @@ declare namespace media { * @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. + * @throws { BusinessError } 5400101 - No memory. Return by callback. + * @systemapi */ function createVideoRecorder(callback: AsyncCallback): void; /** @@ -71,6 +73,8 @@ declare namespace media { * @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. + * @throws { BusinessError } 5400101 - No memory. Return by promise. + * @systemapi */ function createVideoRecorder(): Promise; @@ -662,6 +666,7 @@ declare namespace media { * Describes video recorder states. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ type VideoRecordState = 'idle' | 'prepared' | 'playing' | 'paused' | 'stopped' | 'error'; @@ -670,6 +675,7 @@ declare namespace media { * to create an VideoRecorder instance. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ interface VideoRecorder { /** @@ -679,6 +685,11 @@ declare namespace media { * @param config Recording parameters. * @param callback A callback instance used to return when prepare completed. * @permission ohos.permission.MICROPHONE + * @throws { BusinessError } 201 - Permission denied. Return by callback. + * @throws { BusinessError } 401 - Parameter error. Return by callback. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ prepare(config: VideoRecorderConfig, callback: AsyncCallback): void; /** @@ -688,6 +699,11 @@ declare namespace media { * @param config Recording parameters. * @return A Promise instance used to return when prepare completed. * @permission ohos.permission.MICROPHONE + * @throws { BusinessError } 201 - Permission denied. Return by promise. + * @throws { BusinessError } 401 - Parameter error. Return by promise. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ prepare(config: VideoRecorderConfig): Promise; /** @@ -695,6 +711,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback Callback used to return the input surface id in string. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ getInputSurface(callback: AsyncCallback): void; /** @@ -702,6 +722,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return the input surface id in string. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ getInputSurface(): Promise; /** @@ -709,6 +733,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback A callback instance used to return when start completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ start(callback: AsyncCallback): void; /** @@ -716,6 +744,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return when start completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ start(): Promise; /** @@ -723,6 +755,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback A callback instance used to return when pause completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ pause(callback: AsyncCallback): void; /** @@ -730,6 +766,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return when pause completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ pause(): Promise; /** @@ -737,6 +777,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback A callback instance used to return when resume completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ resume(callback: AsyncCallback): void; /** @@ -744,6 +788,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return when resume completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ resume(): Promise; /** @@ -751,6 +799,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback A callback instance used to return when stop completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by callback. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ stop(callback: AsyncCallback): void; /** @@ -758,6 +810,10 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return when stop completed. + * @throws { BusinessError } 5400102 - Operate not permit. Return by promise. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ stop(): Promise; /** @@ -765,6 +821,8 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback A callback instance used to return when release completed. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ release(callback: AsyncCallback): void; /** @@ -772,6 +830,8 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return when release completed. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ release(): Promise; /** @@ -781,6 +841,9 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @param callback A callback instance used to return when reset completed. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ reset(callback: AsyncCallback): void; /** @@ -790,6 +853,9 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @return A Promise instance used to return when reset completed. + * @throws { BusinessError } 5400103 - IO error. Return by promise. + * @throws { BusinessError } 5400105 - Service died. Return by promise. + * @systemapi */ reset(): Promise; /** @@ -798,6 +864,9 @@ declare namespace media { * @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. + * @throws { BusinessError } 5400103 - IO error. Return by callback. + * @throws { BusinessError } 5400105 - Service died. Return by callback. + * @systemapi */ on(type: 'error', callback: ErrorCallback): void; @@ -805,6 +874,7 @@ declare namespace media { * video recorder state. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly state: VideoRecordState; } @@ -1115,32 +1185,6 @@ declare namespace media { */ 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('availableBitratesCollect')}. 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('availableBitratesCollect')}. 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 @@ -1186,16 +1230,6 @@ declare namespace media { */ 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: 'availableBitratesCollect', callback: (bitrates: Array) => void): void; - /** * Listens for playback error events. * @since 8 @@ -1357,12 +1391,14 @@ declare namespace media { * Provides the video recorder profile definitions. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ interface VideoRecorderProfile { /** * Indicates the audio bit rate. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly audioBitrate: number; @@ -1370,6 +1406,7 @@ declare namespace media { * Indicates the number of audio channels. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly audioChannels: number; @@ -1377,6 +1414,7 @@ declare namespace media { * Indicates the audio encoding format. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly audioCodec: CodecMimeType; @@ -1384,6 +1422,7 @@ declare namespace media { * Indicates the audio sampling rate. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly audioSampleRate: number; @@ -1391,6 +1430,7 @@ declare namespace media { * Indicates the output file format. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly fileFormat: ContainerFormatType; @@ -1398,6 +1438,7 @@ declare namespace media { * Indicates the video bit rate. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly videoBitrate: number; @@ -1405,6 +1446,7 @@ declare namespace media { * Indicates the video encoding format. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly videoCodec: CodecMimeType; @@ -1412,6 +1454,7 @@ declare namespace media { * Indicates the video width. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly videoFrameWidth: number; @@ -1419,6 +1462,7 @@ declare namespace media { * Indicates the video height. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly videoFrameHeight: number; @@ -1426,6 +1470,7 @@ declare namespace media { * Indicates the video frame rate. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ readonly videoFrameRate: number; } @@ -1435,19 +1480,22 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @import import media from '@ohos.multimedia.media' + * @systemapi */ enum AudioSourceType { /** * default audio source type. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder - */ + * @systemapi + */ AUDIO_SOURCE_TYPE_DEFAULT = 0, /** * source type mic. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder - */ + * @systemapi + */ AUDIO_SOURCE_TYPE_MIC = 1, } @@ -1456,19 +1504,22 @@ declare namespace media { * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder * @import import media from '@ohos.multimedia.media' + * @systemapi */ enum VideoSourceType { /** * surface raw data. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ VIDEO_SOURCE_TYPE_SURFACE_YUV = 0, /** * surface ES data. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder - */ + * @systemapi + */ VIDEO_SOURCE_TYPE_SURFACE_ES = 1, } @@ -1476,33 +1527,37 @@ declare namespace media { * Provides the video recorder configuration definitions. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ interface VideoRecorderConfig { /** * audio source type, details see @AudioSourceType . * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ - audioSourceType: AudioSourceType; + audioSourceType?: AudioSourceType; /** * video source type, details see @VideoSourceType . * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ videoSourceType: VideoSourceType; /** * video recorder profile, can get by "getVideoRecorderProfile", details see @VideoRecorderProfile . * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ 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 + * @systemapi */ url: string; /** @@ -1510,12 +1565,14 @@ declare namespace media { * the range of rotation angle should be {0, 90, 180, 270}, default is 0. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ rotation?: number; /** * geographical location information. * @since 9 * @syscap SystemCapability.Multimedia.Media.VideoRecorder + * @systemapi */ location?: Location; } diff --git a/api/@ohos.multimedia.mediaLibrary.d.ts b/api/@ohos.multimedia.mediaLibrary.d.ts index bc5b5a6102a1226ab800b57d4ff8b91620c181d6..18699d7b4580d625c4160d3ad8876a5dac987046 100644 --- a/api/@ohos.multimedia.mediaLibrary.d.ts +++ b/api/@ohos.multimedia.mediaLibrary.d.ts @@ -22,8 +22,6 @@ import image from './@ohos.multimedia.image'; * @since 6 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @import import media from '@ohos.multimedia.mediaLibrary' - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager */ declare namespace mediaLibrary { /** @@ -33,8 +31,6 @@ declare namespace mediaLibrary { * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' * @FAModelOnly * @return Returns a MediaLibrary instance if the operation is successful; returns null otherwise. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.getUserFileMgr */ function getMediaLibrary(): MediaLibrary; /** @@ -44,8 +40,6 @@ declare namespace mediaLibrary { * @StageModelOnly * @param context hap context information * @return Instance of MediaLibrary - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.getUserFileMgr */ function getMediaLibrary(context: Context): MediaLibrary; @@ -53,40 +47,30 @@ declare namespace mediaLibrary { * Enumeration types for different kind of Media Files * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaType */ enum MediaType { /** * File media type * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaType.FILE */ FILE = 0, /** * Image media type * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaType.IMAGE */ IMAGE, /** * Video media type * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaType.VIDEO */ VIDEO, /** * Audio media type * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaType.AUDIO */ AUDIO } @@ -151,123 +135,102 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset */ interface FileAsset { /** * File ID. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly id: number; /** * URI of the file. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.uri */ readonly uri: string; /** * MIME type, for example, video/mp4, audio/mp4, or audio/amr-wb. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.mimeType */ readonly mimeType: string; /** - * Media type, for example, IMAGE, VIDEO, FILE, AUDIO + * Media type, for example, IMAGE, VIDEO, FILE, AUDIO * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly mediaType: MediaType; /** * Display name (with a file name extension) of the file. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.displayName */ displayName: string; /** * File name title (without the file name extension). * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ title: string; /** * Relative Path of the file. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ relativePath: string; /** * Parent folder's file_id of the file. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly parent: number; /** * Data size of the file. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly size: number; /** * Date (timestamp) when the file was added. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly dateAdded: number; /** * Date (timestamp) when the file was modified. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly dateModified: number; /** * Date (timestamp) when the file was taken. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly dateTaken: number; /** * Artist of the audio file. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly artist: string; /** * audioAlbum of the audio file. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly audioAlbum: string; /** * Display width of the file. This is valid only for videos and images. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly width: number; /** * Display height of the file. This is valid only for videos and images. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly height: number; /** @@ -275,35 +238,30 @@ declare namespace mediaLibrary { * The rotation angle can be 0, 90, 180, or 270 degrees. This is valid only for videos. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ orientation: number; /** * duration of the audio and video file. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly duration: number; /** * ID of the album where the file is located. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly albumId: number; /** * URI of the album where the file is located. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly albumUri: string; /** * Name of the album where the file is located. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly albumName: string; @@ -313,8 +271,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA * @param callback Callback return the result of isDerectory. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.isDirectory */ isDirectory(callback: AsyncCallback): void; /** @@ -322,8 +278,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.isDirectory */ isDirectory():Promise; /** @@ -332,8 +286,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA * @param callback no value will be returned. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.commitModify */ commitModify(callback: AsyncCallback): void; /** @@ -341,8 +293,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.commitModify */ commitModify(): Promise; /** @@ -352,8 +302,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.open */ open(mode: string, callback: AsyncCallback): void; /** @@ -362,8 +310,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.open */ open(mode: string): Promise; /** @@ -373,8 +319,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.close */ close(fd: number, callback: AsyncCallback): void; /** @@ -383,8 +327,6 @@ declare namespace mediaLibrary { * @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 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.close */ close(fd: number): Promise; /** @@ -393,8 +335,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA * @param callback Callback used to return the thumbnail's pixelmap. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.getThumbnail */ getThumbnail(callback: AsyncCallback): void; /** @@ -404,8 +344,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @param size thumbnail's size * @param callback Callback used to return the thumbnail's pixelmap. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.getThumbnail */ getThumbnail(size: Size, callback: AsyncCallback): void; /** @@ -414,8 +352,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA * @param size thumbnail's size - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.getThumbnail */ getThumbnail(size?: Size): Promise; /** @@ -425,8 +361,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.favorite */ favorite(isFavorite: boolean, callback: AsyncCallback): void; /** @@ -435,8 +369,6 @@ declare namespace mediaLibrary { * @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 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.favorite */ favorite(isFavorite: boolean): Promise; /** @@ -445,8 +377,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA * @param callback Callback used to return true or false. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.isFavorite */ isFavorite(callback: AsyncCallback): void; /** @@ -454,8 +384,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.isFavorite */ isFavorite():Promise; /** @@ -465,8 +393,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.trash */ trash(isTrash: boolean, callback: AsyncCallback): void; /** @@ -475,8 +401,6 @@ declare namespace mediaLibrary { * @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 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.trash */ trash(isTrash: boolean): Promise; /** @@ -485,8 +409,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA * @param callback Callback used to return true or false. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.isTrash */ isTrash(callback: AsyncCallback): void; /** @@ -494,8 +416,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileAsset.isTrash */ isTrash():Promise; } @@ -504,146 +424,120 @@ declare namespace mediaLibrary { * Describes MediaFetchOptions's selection * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileKey */ enum FileKey { /** * File ID * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ ID = "file_id", /** * Relative Path * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileKey.RELATIVE_PATH */ RELATIVE_PATH = "relative_path", /** * File name * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileKey.DISPLAY_NAME */ DISPLAY_NAME = "display_name", /** * Parent folder file id * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ PARENT = "parent", /** * Mime type of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ MIME_TYPE = "mime_type", /** * Media type of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ MEDIA_TYPE = "media_type", /** * Size of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ SIZE = "size", /** * Date of the file creation * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileKey.DATE_ADDED */ DATE_ADDED = "date_added", /** * Modify date of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileKey.DATE_MODIFIED */ DATE_MODIFIED = "date_modified", /** * Date taken of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ DATE_TAKEN = "date_taken", /** * Title of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FileKey.TITLE */ TITLE = "title", /** * Artist of the audio file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ ARTIST = "artist", /** * Audio album of the audio file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ AUDIOALBUM = "audio_album", /** * Duration of the audio and video file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ DURATION = "duration", /** * Width of the image file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ WIDTH = "width", /** * Height of the image file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ HEIGHT = "height", /** * Orientation of the image file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ ORIENTATION = "orientation", /** * Album id of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ ALBUM_ID = "bucket_id", /** * Album name of the file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ ALBUM_NAME = "bucket_display_name", } @@ -652,52 +546,42 @@ declare namespace mediaLibrary { * Fetch parameters applicable on images, videos, audios, albums and other media * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaFetchOptions */ interface MediaFetchOptions { /** * Fields to retrieve, for example, selections: "media_type =? OR media_type =?". * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaFetchOptions.selections */ selections: string; /** * Conditions for retrieval, for example, selectionArgs: [IMAGE, VIDEO]. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.MediaFetchOptions.selectionArgs */ 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 - * @deprecated since 9 */ order?: string; /** * uri for retrieval * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ uri?: string; /** * networkId for retrieval * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ networkId?: string; /** * extendArgs for retrieval * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ extendArgs?: string; } @@ -707,8 +591,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @import import mediaLibrary from '@ohos.multimedia.mediaLibrary' - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult */ interface FetchFileResult { /** @@ -716,8 +598,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @return Total number of files. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getCount */ getCount(): number; /** @@ -725,8 +605,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @return Whether the file is the last one. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.isAfterLast * 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. */ @@ -735,8 +613,6 @@ declare namespace mediaLibrary { * Releases the FetchFileResult instance and invalidates it. Other methods cannot be called. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.close */ close(): void; /** @@ -744,8 +620,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param callback Callback used to return the file in the format of a FileAsset instance. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getFirstObject */ getFirstObject(callback: AsyncCallback): void; /** @@ -753,8 +627,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @return A Promise instance used to return the file in the format of a FileAsset instance. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getFirstObject */ getFirstObject(): Promise; /** @@ -765,8 +637,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param callback Callback used to return the file in the format of a FileAsset instance. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getNextObject */ getNextObject(callback: AsyncCallback): void; /** @@ -777,8 +647,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @return A Promise instance used to return the file in the format of a FileAsset instance. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getNextObject */ getNextObject(): Promise; /** @@ -786,8 +654,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param callback Callback used to return the file in the format of a FileAsset instance. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getLastObject */ getLastObject(callback: AsyncCallback): void; /** @@ -795,8 +661,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @return A Promise instance used to return the file in the format of a FileAsset instance. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getLastObject */ getLastObject(): Promise; /** @@ -806,8 +670,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getPositionObject */ getPositionObject(index: number, callback: AsyncCallback): void; /** @@ -817,19 +679,16 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.FetchFileResult.getPositionObject */ 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, + * 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. - * @deprecated since 9 */ getAllObject(callback: AsyncCallback>): void; /** @@ -840,7 +699,6 @@ declare namespace mediaLibrary { * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @return A Promise instance used to return a FileAsset array. - * @deprecated since 9 */ getAllObject(): Promise>; } @@ -850,63 +708,48 @@ declare namespace mediaLibrary { * * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @since 7 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album */ interface Album { /** * Album ID. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 */ readonly albumId: number; /** * Album name. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.albumName */ albumName: string; /** * Album uri. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.albumUri */ readonly albumUri: string; /** * Date (timestamp) when the album was last modified. * @since 7 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.dateModified */ readonly dateModified: number; /** * File count for the album * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.count */ readonly count: number; /** * Relative path for the album * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.relativePath */ readonly relativePath: string; /** * coverUri for the album * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.coverUri */ readonly coverUri: string; @@ -916,8 +759,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA * @param callback, no value will be returned. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.commitModify */ commitModify(callback: AsyncCallback): void; /** @@ -925,8 +766,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @permission ohos.permission.READ_MEDIA and ohos.permission.WRITE_MEDIA - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.commitModify */ commitModify(): Promise; /** @@ -935,8 +774,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.getFileAssets */ getFileAssets(callback: AsyncCallback): void; /** @@ -946,8 +783,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.getFileAssets */ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void; /** @@ -957,8 +792,6 @@ declare namespace mediaLibrary { * @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. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Album.getFileAssets */ getFileAssets(options?: MediaFetchOptions): Promise; } @@ -967,56 +800,42 @@ declare namespace mediaLibrary { * Enumeration public directory that predefined * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType */ enum DirectoryType { /** * predefined public directory for files token by Camera. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType.DIR_CAMERA */ DIR_CAMERA = 0, /** * predefined public directory for VIDEO files. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType.DIR_VIDEO */ DIR_VIDEO, /** * predefined public directory for IMAGE files. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType.DIR_IMAGE */ DIR_IMAGE, /** * predefined public directory for AUDIO files. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType.DIR_AUDIO */ DIR_AUDIO, /** * predefined public directory for DOCUMENTS files. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType.DIR_DOCUMENTS */ DIR_DOCUMENTS, /** * predefined public directory for DOWNLOAD files. * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.DirectoryType.DIR_DOWNLOAD */ DIR_DOWNLOAD } @@ -1026,8 +845,6 @@ declare namespace mediaLibrary { * * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @since 6 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager */ interface MediaLibrary { /** @@ -1036,8 +853,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param type, public directory predefined in DirectoryType. * @param callback Callback return the FetchFileResult. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getPublicDirectory */ getPublicDirectory(type: DirectoryType, callback: AsyncCallback): void; /** @@ -1046,8 +861,6 @@ declare namespace mediaLibrary { * @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 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getPublicDirectory */ getPublicDirectory(type: DirectoryType): Promise; /** @@ -1058,8 +871,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @param options, Media retrieval options. * @param callback, Callback return the FetchFileResult. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getFileAssets */ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback): void; /** @@ -1070,8 +881,6 @@ declare namespace mediaLibrary { * @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 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getFileAssets */ getFileAssets(options: MediaFetchOptions): Promise; /** @@ -1080,8 +889,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param type one of 'deviceChange','albumChange','imageChange','audioChange','videoChange','fileChange','remoteFileChange' * @param callback no value returned - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.on */ on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback: Callback): void; /** @@ -1090,8 +897,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param type one of 'deviceChange','albumChange','imageChange','audioChange','videoChange','fileChange','remoteFileChange' * @param callback no value returned - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.off */ off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback?: Callback): void; /** @@ -1103,8 +908,6 @@ declare namespace mediaLibrary { * @param displayName file name * @param relativePath relative path * @param callback Callback used to return the FileAsset - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.createAsset */ createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback): void; /** @@ -1116,8 +919,6 @@ declare namespace mediaLibrary { * @param displayName file name * @param relativePath relative path * @return A Promise instance used to return the FileAsset - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.createAsset */ createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise; /** @@ -1128,8 +929,6 @@ declare namespace mediaLibrary { * @param uri FileAsset's URI * @param callback no value returned * @systemapi - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.deleteAsset */ deleteAsset(uri: string, callback: AsyncCallback): void; /** @@ -1140,8 +939,6 @@ declare namespace mediaLibrary { * @param uri, FileAsset's URI * @return A Promise instance, no value returned * @systemapi - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.deleteAsset */ deleteAsset(uri: string): Promise; /** @@ -1151,8 +948,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @param option Media retrieval options. * @param callback Callback used to return an album array. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getAlbums */ getAlbums(options: MediaFetchOptions, callback: AsyncCallback>): void; /** @@ -1162,8 +957,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @param option Media retrieval options. * @return A Promise instance used to return an album array. - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getAlbums */ getAlbums(options: MediaFetchOptions): Promise>; /** @@ -1243,8 +1036,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @systemapi * @param callback, Callback return the list of the active peer devices' information - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getActivePeers */ getActivePeers(callback: AsyncCallback>): void; /** @@ -1254,8 +1045,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @systemapi * @return Promise used to return the list of the active peer devices' information - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getActivePeers */ getActivePeers(): Promise>; /** @@ -1265,8 +1054,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @systemapi * @param callback Callback return the list of the all the peer devices' information - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getAllPeers */ getAllPeers(callback: AsyncCallback>): void; /** @@ -1276,8 +1063,6 @@ declare namespace mediaLibrary { * @permission ohos.permission.READ_MEDIA * @systemapi * @return Promise used to return the list of the all the peer devices' information - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.getAllPeers */ getAllPeers(): Promise>; /** @@ -1285,16 +1070,12 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @param callback no value returned - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.release */ release(callback: AsyncCallback): void; /** * Release MediaLibrary instance * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.UserFileManager.release */ release(): Promise; } @@ -1303,43 +1084,33 @@ declare namespace mediaLibrary { * thumbnail's size which have width and heigh * @syscap SystemCapability.Multimedia.MediaLibrary.Core * @since 8 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Size */ interface Size { /** * Width of image file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Size.width */ width: number; /** * Height of image file * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.Core - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.Size.height */ height: number; } - + /** * peer devices' information * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi * @since 8 - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.PeerInfo */ interface PeerInfo { /** * Peer device name * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.PeerInfo.deviceName * @systemapi */ readonly deviceName: string; @@ -1347,8 +1118,6 @@ declare namespace mediaLibrary { * Peer device network id * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.PeerInfo.networkId * @systemapi */ readonly networkId: string; @@ -1356,7 +1125,6 @@ declare namespace mediaLibrary { * Peer device type * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore - * @deprecated since 9 * @systemapi */ readonly deviceType: DeviceType; @@ -1365,8 +1133,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 - * @useinstead ohos.filemanagement.UserFileManager.PeerInfo.isOnline */ readonly isOnline: boolean; } @@ -1376,7 +1142,6 @@ declare namespace mediaLibrary { * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi * @since 8 - * @deprecated since 9 */ enum DeviceType { /** @@ -1384,7 +1149,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_UNKNOWN = 0, /** @@ -1392,7 +1156,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_LAPTOP, /** @@ -1400,7 +1163,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_PHONE, /** @@ -1408,7 +1170,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_TABLET, /** @@ -1416,7 +1177,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_WATCH, /** @@ -1424,7 +1184,6 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_CAR, /** @@ -1432,10 +1191,9 @@ declare namespace mediaLibrary { * @since 8 * @syscap SystemCapability.Multimedia.MediaLibrary.DistributedCore * @systemapi - * @deprecated since 9 */ TYPE_TV } } -export default mediaLibrary; +export default mediaLibrary; \ No newline at end of file diff --git a/api/@ohos.net.connection.d.ts b/api/@ohos.net.connection.d.ts index 84576eeee742051a4a1807706e0eb3e49fe14f02..283d7bef593de0ab92675dd186438e86a124b014 100644 --- a/api/@ohos.net.connection.d.ts +++ b/api/@ohos.net.connection.d.ts @@ -56,6 +56,7 @@ declare namespace connection { * returns {@code null} if the default network is not activated. * @permission ohos.permission.GET_NETWORK_INFO * @since 9 + * @throws {BusinessError} 201 - Permission denied. */ function getDefaultNetSync(): NetHandle; @@ -88,6 +89,18 @@ declare namespace connection { function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback): void; function getNetCapabilities(netHandle: NetHandle): Promise; + /** + * Checks whether data traffic usage on the current network is metered. + * + * @param callback Returns {@code true} if data traffic usage on the current network is metered; + * returns {@code false} otherwise. + * @permission ohos.permission.GET_NETWORK_INFO + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + */ + function isDefaultNetMetered(callback: AsyncCallback): void; + function isDefaultNetMetered(): Promise; + /** * Checks whether the default data network is activated. * diff --git a/api/@ohos.net.socket.d.ts b/api/@ohos.net.socket.d.ts index 3fcdd5c8f99714b285935773210c22b68e1fa585..1f6d090abdb7f37020ea51cea687dfe455b23727 100644 --- a/api/@ohos.net.socket.d.ts +++ b/api/@ohos.net.socket.d.ts @@ -341,10 +341,100 @@ declare namespace socket { /** * @since 9 */ - export interface TLSSocket extends TCPSocket { + export interface TLSSocket { + + /** + * 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 + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 2303198 - Address already in use. + * @throws {BusinessError} 2300002 - System internal error. + */ + bind(address: NetAddress, callback: AsyncCallback): void; + bind(address: NetAddress): Promise; + + /** + * Obtains the peer address of a TLSSocket connection. + * + * @param callback Callback used to return the result. {@link NetAddress} + * @throws {BusinessError} 2303188 - Socket operation on non-socket. + * @throws {BusinessError} 2300002 - System internal error. + */ + getRemoteAddress(callback: AsyncCallback): void; + getRemoteAddress(): Promise; + + /** + * Obtains the status of the TLSSocket connection. + * + * @param callback Callback used to return the result. {@link SocketStateBase} + * @throws {BusinessError} 2303188 - Socket operation on non-socket. + * @throws {BusinessError} 2300002 - System internal error. + */ + getState(callback: AsyncCallback): void; + getState(): Promise; + + /** + * Sets other attributes of the TLSSocket connection. + * + * @param options Optional parameters {@link TCPExtraOptions}. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303188 - Socket operation on non-socket. + * @throws {BusinessError} 2300002 - System internal error. + */ + setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback): void; + setExtraOptions(options: TCPExtraOptions): Promise; + + /** + * Listens for message receiving events of the TLSSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. + */ + on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Cancels listening for message receiving events of the TLSSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. + */ + off(type: 'message', callback?: Callback<{message: ArrayBuffer, remoteInfo: SocketRemoteInfo}>): void; + + /** + * Listens for connection or close events of the TLSSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. + */ + on(type: 'connect' | 'close', callback: Callback): void; + + /** + * Cancels listening for connection or close events of the TLSSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. + */ + off(type: 'connect' | 'close', callback?: Callback): void; + + /** + * Listens for error events of the TLSSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. + */ + on(type: 'error', callback: ErrorCallback): void; + + /** + * Cancels listening for error events of the TLSSocket connection. + * + * @throws {BusinessError} 401 - Parameter error. + */ + off(type: 'error', callback?: ErrorCallback): void; /** * Returns an object representing a local certificate. + * + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2303504 - Error looking up x509 + * @throws {BusinessError} 2300002 - System internal error. */ getCertificate(callback: AsyncCallback): void; getCertificate(): Promise; @@ -354,6 +444,9 @@ declare namespace socket { * an empty object will be returned. If the socket is destroyed, null is returned. * If needChain is true, it contains the complete certificate chain. Otherwise, * it only contains the peer's certificate. + * + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2300002 - System internal error. */ getRemoteCertificate(callback: AsyncCallback): void; getRemoteCertificate(): Promise; @@ -362,6 +455,10 @@ declare namespace socket { * Returns a string containing the negotiated SSL/TLS protocol version of the current connection. * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned. * Server sockets or disconnected client sockets will return a value of null. + * + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2303505 - Error occurred in the tls system call. + * @throws {BusinessError} 2300002 - System internal error. */ getProtocol(callback: AsyncCallback): void; getProtocol(): Promise; @@ -369,6 +466,11 @@ declare namespace socket { /** * Returns an object containing the negotiated cipher suite information. * For example:{"name": "AES128-SHA256", "standardName": "TLS_RSA_WITH_AES_128_CBC_SHA256", "version": "TLSv1.2"} + * + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2303502 - Error in tls reading. + * @throws {BusinessError} 2303505 - Error occurred in the tls system call. + * @throws {BusinessError} 2300002 - System internal error. */ getCipherSuite(callback: AsyncCallback>): void; getCipherSuite(): Promise>; @@ -376,12 +478,30 @@ declare namespace socket { /** * The list of signature algorithms shared between the server and the client, in descending order of priority. * @see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html + * + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2300002 - System internal error. */ getSignatureAlgorithms(callback: AsyncCallback>): void; getSignatureAlgorithms(): Promise>; /** - * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303104 - Interrupted system call. + * @throws {BusinessError} 2303109 - Bad file number. + * @throws {BusinessError} 2303111 - Resource temporarily unavailable try again. + * @throws {BusinessError} 2303113 - System permission denied. + * @throws {BusinessError} 2303188 - Socket operation on non-socket. + * @throws {BusinessError} 2303191 - Protocol wrong type for socket. + * @throws {BusinessError} 2303198 - Address already in use. + * @throws {BusinessError} 2303199 - Cannot assign requested address. + * @throws {BusinessError} 2303210 - Connection timed out. + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2303502 - Error in tls reading. + * @throws {BusinessError} 2303503 - Error in tls writing + * @throws {BusinessError} 2303505 - Error occurred in the tls system call. + * @throws {BusinessError} 2303506 - Error clearing tls connection. + * @throws {BusinessError} 2300002 - System internal error. */ connect(options: TLSConnectOptions, callback: AsyncCallback): void; connect(options: TLSConnectOptions): Promise; @@ -390,10 +510,27 @@ declare namespace socket { * Sends data over a TLSSocket connection. * * @param data Optional parameters {@link string}. - * @permission ohos.permission.INTERNET + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2303503 - Error in tls writing. + * @throws {BusinessError} 2303505 - Error occurred in the tls system call. + * @throws {BusinessError} 2303506 - Error clearing tls connection. + * @throws {BusinessError} 2300002 - System internal error. */ send(data: string, callback: AsyncCallback): void; send(data: string): Promise; + + /** + * Closes a TLSSocket connection + * + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 2303501 - SSL is null. + * @throws {BusinessError} 2303505 - Error occurred in the tls system call. + * @throws {BusinessError} 2303506 - Error clearing tls connection. + * @throws {BusinessError} 2300002 - System internal error. + */ + close(callback: AsyncCallback): void; + close(): Promise; } /** diff --git a/api/@ohos.nfc.tag.d.ts b/api/@ohos.nfc.tag.d.ts index 1543c240c68a18bd16c405eceecb04212a9d185a..20ac89240b326b0e8ddc0e072d06fd10a65241e4 100644 --- a/api/@ohos.nfc.tag.d.ts +++ b/api/@ohos.nfc.tag.d.ts @@ -56,18 +56,18 @@ declare namespace tag { /** Indicates an NDEF tag. */ const NDEF = 6; - /** Indicates a MifareClassic tag. */ - const MIFARE_CLASSIC = 8; - - /** Indicates a MifareUltralight tag. */ - const MIFARE_ULTRALIGHT = 9; - /** - * Indicates an NdefFormatable tag. + * Indicates an NDEF Formatable tag. * * @since 9 */ - const NDEF_FORMATABLE = 10; + const NDEF_FORMATABLE = 7; + + /** Indicates a MIFARE Classic tag. */ + const MIFARE_CLASSIC = 8; + + /** Indicates a MIFARE Ultralight tag. */ + const MIFARE_ULTRALIGHT = 9; /** * TNF types definitions, see NFCForum-TS-NDEF_1.0. @@ -99,7 +99,7 @@ declare namespace tag { } /** - * NfcForum Type definition. The Ndef tag may use one of them. + * NfcForum Type definition. The NDEF tag may use one of them. * * @since 9 * @syscap SystemCapability.Communication.NFC.Core @@ -247,75 +247,85 @@ declare namespace tag { /** * Obtains an {@link IsoDepTag} object based on the tag information. * - *

          During tag reading, if the tag supports the IsoDep technology, an {@link IsoDepTag} object + * 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 - * + * @param { TagInfo } tagInfo - Indicates the diapatched tag information. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ - function getIsoDepTag(tagInfo: TagInfo): IsoDepTag + function getIsoDep(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 + * 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 - * + * @param { TagInfo } tagInfo - Indicates the diapatched tag information. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ - function getNdefTag(tagInfo: TagInfo): NdefTag + function getNdef(tagInfo: TagInfo): NdefTag /** * Obtains an {@link MifareClassicTag} object based on the tag information. * - *

          During tag reading, if the tag supports the MifareClassic technology, + * During tag reading, if the tag supports the MIFARE Classic technology, * an {@link MifareClassicTag} object will be created based on the tag information. * - * @param tagInfo Indicates the tag information. - * @permission ohos.permission.NFC_TAG - * + * @param { TagInfo } tagInfo - Indicates the diapatched tag information. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ - function getMifareClassicTag(tagInfo: TagInfo): MifareClassicTag + function getMifareClassic(tagInfo: TagInfo): MifareClassicTag /** * Obtains an {@link MifareUltralightTag} object based on the tag information. * - *

          During tag reading, if the tag supports the MifareUltralight technology, + * During tag reading, if the tag supports the MIFARE Ultralight technology, * an {@link MifareUltralightTag} object will be created based on the tag information. * - * @param tagInfo Indicates the tag information. - * @permission ohos.permission.NFC_TAG - * + * @param { TagInfo } tagInfo - Indicates the diapatched tag information. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ - function getMifareUltralightTag(tagInfo: TagInfo): MifareUltralightTag + function getMifareUltralight(tagInfo: TagInfo): MifareUltralightTag /** * Obtains an {@link NdefFormatableTag} object based on the tag information. * - *

          During tag reading, if the tag supports the NdefFormatable technology, + * During tag reading, if the tag supports the NDEF Formatable technology, * an {@link NdefFormatableTag} object will be created based on the tag information. * - * @param tagInfo Indicates the tag information. - * @permission ohos.permission.NFC_TAG - * + * @param { TagInfo } tagInfo - Indicates the diapatched tag information. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ - function getNdefFormatableTag(tagInfo: TagInfo): NdefFormatableTag + function getNdefFormatable(tagInfo: TagInfo): NdefFormatableTag /** * Parse a {@link TagInfo} object from Want. * - * @param want The want object that contains the values of TagInfo. - * @return The TagInfo object that's parsed. + * @param { Want } want - The want object that contains the values of TagInfo. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 801 - Capability not supported. * @syscap SystemCapability.Communication.NFC.Core - * @permission ohos.permission.NFC_TAG * @since 9 */ function getTagInfo(want: Want): TagInfo @@ -398,6 +408,88 @@ declare namespace tag { payload: number[]; } + namespace ndef { + /** + * Creates an NDEF record with uri data. + * + * @param { string } uri - Uri data for new NDEF record. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeUriRecord(uri: string): NdefRecord; + + /** + * Creates an NDEF record with text data. + * + * @param { string } text - Text data for new an NDEF record. + * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeTextRecord(text: string, locale: string): NdefRecord; + + /** + * Creates an NDEF record with mime data. + * + * @param { string } mimeType type of mime data for new an NDEF record. + * @param { string } mimeData mime data for new an NDEF record. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeMimeRecord(mimeType: string, mimeData: number[]): NdefRecord; + + /** + * Creates an NDEF record with external data. + * + * @param { string } domainName - Domain name of issuing organization for the external data. + * @param { string } type - Domain specific type of data for the external data. + * @param { number[] } externalData - Data payload of an NDEF record. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeExternalRecord(domainName: string, type: string, externalData: number[]): NdefRecord; + /** + * Creates an NDEF message with raw bytes. + * + * @param { number[] } data - The raw bytes to parse NDEF message. + * @return { NdefMessage } The instance of NdefMessage. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function createNdefMessage(data: number[]): NdefMessage; + + /** + * Creates an NDEF message with record list. + * + * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. + * @return { NdefMessage } The instance of NdefMessage. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; + + /** + * Parses an NDEF message into raw bytes. + * + * @param { NdefMessage } ndefMessage - An NDEF message to parse. + * @return { number[] } Returns the raw bytes of an NDEF message. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function messageToBytes(ndefMessage: NdefMessage): number[]; + } + export type NfcATag = _NfcATag export type NfcBTag = _NfcBTag export type NfcFTag = _NfcFTag diff --git a/api/@ohos.notification.d.ts b/api/@ohos.notification.d.ts index 9f9beac74a1abd7b35c879012be22866541fac3f..de8c1ae964c8f72e7c88fe2137b74e05d63fd643 100644 --- a/api/@ohos.notification.d.ts +++ b/api/@ohos.notification.d.ts @@ -1135,7 +1135,7 @@ declare namespace notification { * Describes a NotificationFlags instance. * * @since 9 - * @permission N/A + * @systemapi Hide this for inner system use. * @syscap SystemCapability.Notification.Notification * @deprecated since 9 * @useinstead ohos.notificationManager.NotificationFlags diff --git a/api/@ohos.notificationManager.d.ts b/api/@ohos.notificationManager.d.ts index b7f53c64819767892695dcb13e13221271cb7d37..e35bfb4fcd63f8a38601ceed08799d05c114649a 100644 --- a/api/@ohos.notificationManager.d.ts +++ b/api/@ohos.notificationManager.d.ts @@ -1341,6 +1341,7 @@ declare namespace notificationManager { /** * Describes a NotificationFlags instance. * @syscap SystemCapability.Notification.Notification + * @systemapi * @since 9 */ export type NotificationFlags = _NotificationFlags diff --git a/api/@ohos.power.d.ts b/api/@ohos.power.d.ts index 40a4bf29995884d3e4844916ca18b93028275c0f..11e3384bf45c1fdf00cd0f702d022c48816d0170 100644 --- a/api/@ohos.power.d.ts +++ b/api/@ohos.power.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import {AsyncCallback} from './basic'; +import {AsyncCallback, BusinessError} from './basic'; /** * Provides interfaces to manage power. @@ -22,103 +22,156 @@ import {AsyncCallback} from './basic'; * @since 7 */ declare namespace power { - /** - * Shuts down the system. - * - *

          This method requires the ohos.permission.REBOOT permission. - * - * @param reason Indicates the shutdown reason. - * @permission ohos.permission.REBOOT - * @systemapi - * @since 7 - */ - function shutdownDevice(reason: string): void; + /** + * Shuts down the system. + * + *

          This method requires the ohos.permission.REBOOT permission. + * + * @permission ohos.permission.REBOOT + * @param {string} reason Indicates the shutdown reason. + * @throws {BusinessError} 201 - If the permission is denied. + * @throws {BusinessError} 401 - If the reason is not valid. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @systemapi + * @since 7 + */ + function shutdown(reason: string): void; - /** - * 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; + /** + * Restarts the system. + * + *

          This method requires the ohos.permission.REBOOT permission. + * + * @param reason Indicates the restart reason. For example, "updater" indicates entering 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 + * @deprecated since 9 + * @useinstead {@link power#reboot} + */ + 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; + /** + * Restarts the system. + * + *

          This method requires the ohos.permission.REBOOT permission. + * + * @permission ohos.permission.REBOOT + * @param {string} reason Indicates the restart reason. For example, "updater" indicates entering the updater mode + * after the restart. If the parameter is not specified, the system enters the normal mode after the restart. + * @throws {BusinessError} 201 - If the permission is denied. + * @throws {BusinessError} 401 - If the reason is not valid. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @systemapi + * @since 9 + */ + function reboot(reason: string): void; - /** - * Wakes up the device to turn on the screen. - * - * @param detail Indicates the detailed wakeup information. - * @systemapi - * @since 9 - */ - function wakeupDevice(detail: 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 + * @deprecated since 9 + * @useinstead {@link power#isActive} + */ + function isScreenOn(callback: AsyncCallback): void; + function isScreenOn(): Promise; - /** - * Suspends the device to turn off the screen. - * - * @systemapi - * @since 9 - */ - function suspendDevice(): void; + /** + * Checks whether the device is active. + *

          + * The screen will be on if device is active, screen will be off otherwise. + * + * @return Returns true if the device is active; returns false otherwise. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @since 9 + */ + function isActive(): boolean; - /** - * 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; + /** + * Wakes up the device to turn on the screen. + * + * @param {string} detail Indicates the detail information who request wakeup. + * @throws {BusinessError} 401 - If the detail is not valid. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @systemapi + * @since 9 + */ + function wakeup(detail: string): void; - /** - * Sets the power mode of current device. For details, see {@link DevicePowerMode}. - * - * @param mode Indicates the power mode to set. - * @permission ohos.permission.POWER_OPTIMIZATION - * @systemapi - * @since 9 - */ - function setPowerMode(mode: DevicePowerMode, callback: AsyncCallback): void; - function setPowerMode(mode: DevicePowerMode): Promise; + /** + * Suspends the device to turn off the screen. + * + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @systemapi + * @since 9 + */ + function suspend(): void; - /** - * 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 - } + /** + * Obtains the power mode of the current device. For details, see {@link DevicePowerMode}. + * + * @permission ohos.permission.POWER_OPTIMIZATION + * @return The power mode {@link DevicePowerMode} of current device . + * @throws {BusinessError} 201 – If the permission is denied. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @since 9 + */ + function getPowerMode(): DevicePowerMode; + + /** + * Obtains the power mode of the current device. For details, see {@link DevicePowerMode}. + * + * @permission ohos.permission.POWER_OPTIMIZATION + * @param {DevicePowerMode} mode Indicates power mode {@link DevicePowerMode} to set. + * @param {AsyncCallback} callback Indicates the callback of setting the power mode. + * @throws {BusinessError} 201 – If the permission is denied. + * @throws {BusinessError} 401 - If mode or callback is not valid. + * @systemapi + * @since 9 + */ + function setPowerMode(mode: DevicePowerMode, callback: AsyncCallback): void; + + /** + * Sets the power mode of current device. For details, see {@link DevicePowerMode}. + * + * @permission ohos.permission.POWER_OPTIMIZATION + * @param {DevicePowerMode} mode Indicates power mode {@link DevicePowerMode} to set. + * @throws {BusinessError} 201 – If the permission is denied. + * @throws {BusinessError} 401 - If mode or callback is not valid. + * @systemapi + * @since 9 + */ + function setPowerMode(mode: DevicePowerMode): 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/api/@ohos.process.d.ts b/api/@ohos.process.d.ts index 39f8897d6efd4d83745c85797449aee2bcea95b2..875e6dd2c16ba15a32be5b15a8c886f41622fb55 100644 --- a/api/@ohos.process.d.ts +++ b/api/@ohos.process.d.ts @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Huawei Device Co., Ltd. +* 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 @@ -30,69 +30,70 @@ declare namespace process { */ export interface ChildProcess { /** - * return pid is the pid of the current process + * Return pid is the pid of the current process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the pid of the current process. + * @return Return the pid of the current process. */ readonly pid: number; + /** - * return ppid is the pid of the current child process + * Return ppid is the pid of the current child process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the pid of the current child process. + * @return Return the pid of the current child process. */ readonly ppid: number; /** - * return exitCode is the exit code of the current child process + * Return exitCode is the exit code of the current child process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the exit code of the current child process. + * @return Return the exit code of the current child process. */ readonly exitCode: number; /** - * return boolean is whether the current process signal is sent successfully + * Return boolean is whether the current process signal is sent successfully * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return whether the current process signal is sent successfully. + * @return Return whether the current process signal is sent successfully. */ readonly killed: boolean; /** - * return 'number' is the target process exit code + * Return 'number' is the target process exit code * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the target process exit code. + * @return Return the target process exit code. */ wait(): Promise; /** - * return it as 'Uint8Array' of the stdout until EOF + * Return it as 'Uint8Array' of the stdout until EOF * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return subprocess standard outpute. + * @return Return subprocess standard outpute. */ getOutput(): Promise; /** - * return it as 'Uint8Array of the stderr until EOF + * Return it as 'Uint8Array of the stderr until EOF * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return subprocess standard error output. + * @return Return subprocess standard error output. */ getErrorOutput(): Promise; /** - * close the target process + * Close the target process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use @@ -100,73 +101,152 @@ declare namespace process { close(): void; /** - * send a signal to process + * Send a signal to process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @param signal number or string represents the signal sent. + * @param signal Number or string represents the signal sent. */ kill(signal: number | string): void; } /** - * returns the numeric valid group ID of the process + * 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. + * @name ProcessManager + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + export class ProcessManager { + /** + * Returns a boolean whether the specified uid belongs to a particular application. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param v An id. + * @return Return a boolean whether the specified uid belongs to a particular application. + * @throws {BusinessError} 401 - The type of v must be number. + */ + isAppUid(v: number): boolean; + + /** + * Returns the uid based on the specified user name. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param v Process name. + * @return Return the uid based on the specified user name. + * @throws {BusinessError} 401 - The type of v must be string. + */ + getUidForName(v: string): number; + + /** + * Returns the thread priority based on the specified tid. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param v The tid of the process. + * @return Return the thread priority based on the specified tid. + * @throws {BusinessError} 401 - The type of v must be number. + */ + getThreadPriority(v: number): number; + + /** + * Returns the system configuration at runtime. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param name Parameters defined by the system configuration. + * @return Return the system configuration at runtime. + * @throws {BusinessError} 401 - The type of name must be number. + */ + getSystemConfig(name: number): number; + + /** + * Returns the system value for environment variables. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param name Parameters defined by the system environment variables. + * @Returns the system value for environment variables. + * @throws {BusinessError} 401 - The type of name must be string. + */ + getEnvironmentVar(name: string): string; + + /** + * Process exit + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param code Process exit code. + * @throws {BusinessError} 401 - The type of code must be number. + */ + exit(code: number): void; + + /** + * Return whether the signal was sent successfully + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param signal Signal sent. + * @param pid Send signal to target pid. + * @return Return the result of the signal. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + kill(signal: number, pid: number): boolean; + } + + /** + * Returns the numeric valid group ID of the process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the numeric valid group ID of the process. + * @return Return the numeric valid group ID of the process. */ const egid: number; /** - * return the numeric valid user identity of the process + * Return the numeric valid user identity of the process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the numeric valid user identity of the process. + * @return Return the numeric valid user identity of the process. */ const euid: number; /** - * returns the numeric group id of the process + * Returns the numeric group id of the process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return the numeric group if of the process. + * @return Return the numeric group if of the process. */ const gid: number /** - * returns the digital user id of the process + * Returns the digital user id of the process * @since 7 * @syscap SystemCapability.Utils.Lang - * @return return the digital user id of the process. + * @return Return the digital user id of the process. */ const uid: number; /** - * return an array with supplementary group id + * Return an array with supplementary group id * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return an array with supplementary group id. + * @return Return an array with supplementary group id. */ const groups: number[]; /** - * return pid is The pid of the current process + * Return pid is The pid of the current process * @since 7 * @syscap SystemCapability.Utils.Lang - * @return return The pid of the current process. + * @return Return The pid of the current process. */ const pid: number; /** - * return ppid is The pid of the current child process + * Return ppid is The pid of the current child process * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use - * @return return The pid of the current child process. + * @return Return The pid of the current child process. */ const ppid: number; @@ -174,7 +254,7 @@ declare namespace process { * Returns the tid of the current thread. * @since 8 * @syscap SystemCapability.Utils.Lang - * @return return the tid of the current thread. + * @return Return the tid of the current thread. */ const tid: number; @@ -182,16 +262,18 @@ declare namespace process { * Returns a boolean whether the process is isolated. * @since 8 * @syscap SystemCapability.Utils.Lang - * @return return boolean whether the process is isolated. + * @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 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.isAppUid * @syscap SystemCapability.Utils.Lang * @param v An id. - * @return return a boolean whether the specified uid belongs to a particular application. + * @return Return a boolean whether the specified uid belongs to a particular application. */ function isAppUid(v: number): boolean; @@ -199,22 +281,26 @@ declare namespace process { * 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. + * @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 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.getUidForName * @syscap SystemCapability.Utils.Lang * @param v Process name. - * @return return the uid based on the specified user 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 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.getThreadPriority * @syscap SystemCapability.Utils.Lang * @param v The tid of the process. * @return Return the thread priority based on the specified tid. @@ -240,6 +326,8 @@ declare namespace process { /** * Returns the system configuration at runtime. * @since 8 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.getSystemConfig * @syscap SystemCapability.Utils.Lang * @param name Parameters defined by the system configuration. * @return Return the system configuration at runtime. @@ -249,6 +337,8 @@ declare namespace process { /** * Returns the system value for environment variables. * @since 8 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.getEnvironmentVar * @syscap SystemCapability.Utils.Lang * @param name Parameters defined by the system environment variables. * @Returns the system value for environment variables. @@ -260,7 +350,7 @@ declare namespace process { * Return a child process object and spawns a new ChildProcess to run the command * @since 7 * @syscap SystemCapability.Utils.Lang - * @param command string of the shell commands executed by the child process. + * @param command String of the shell commands executed by the child process. * @param options This is an object. The object contains three parameters. Timeout is the running time of the child * process, killSignal is the signal sent when the child process reaches timeout, and maxBuffer is the size of the * maximum buffer area for standard input and output. @@ -300,6 +390,8 @@ declare namespace process { /** * Process exit * @since 7 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.exit * @syscap SystemCapability.Utils.Lang * @param code Process exit code. */ @@ -315,7 +407,7 @@ declare namespace process { function cwd(): string; /** - * Change current directory + * Change current directory * @since 7 * @syscap SystemCapability.Utils.Lang * @systemapi Hide this for inner system use @@ -334,6 +426,8 @@ declare namespace process { /** * Return whether the signal was sent successfully * @since 7 + * @deprecated since 9 + * @useinstead ohos.process.ProcessManager.kill * @syscap SystemCapability.Utils.Lang * @param signal Signal sent. * @param pid Send signal to target pid. diff --git a/api/@ohos.promptAction.d.ts b/api/@ohos.promptAction.d.ts index 478755f04b2caa6eec89a4a15f91b8f6702286b0..468512dbbb55a44d08cff1307a9d763a74af7f5a 100644 --- a/api/@ohos.promptAction.d.ts +++ b/api/@ohos.promptAction.d.ts @@ -214,4 +214,4 @@ declare namespace promptAction { function showActionMenu(options: ActionMenuOptions): Promise; } -export default prompt; +export default promptAction; diff --git a/api/@ohos.reminderAgent.d.ts b/api/@ohos.reminderAgent.d.ts index d6d9878513bb9dd74dc8891d01ce90da89a1254e..189240f5242db95a289c5e6b939210f7967f11fd 100644 --- a/api/@ohos.reminderAgent.d.ts +++ b/api/@ohos.reminderAgent.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -24,6 +24,8 @@ import { NotificationSlot } from './notification/notificationSlot'; * @since 7 * @syscap SystemCapability.Notification.ReminderAgent * @import reminderAgent from '@ohos.reminderAgent'; + * @deprecated since 9 + * @useinstead reminderAgentManager */ declare namespace reminderAgent { /** @@ -35,6 +37,8 @@ declare namespace reminderAgent { * @param reminderReq Indicates the reminder instance to publish. * @param callback Indicates the callback function. * @returns reminder id. + * @deprecated since 9 + * @useinstead reminderAgentManager.publishReminder */ function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void; function publishReminder(reminderReq: ReminderRequest): Promise; @@ -46,6 +50,8 @@ declare namespace reminderAgent { * @syscap SystemCapability.Notification.ReminderAgent * @param reminderId Indicates the reminder id. * @param callback Indicates the callback function. + * @deprecated since 9 + * @useinstead reminderAgentManager.cancelReminder */ function cancelReminder(reminderId: number, callback: AsyncCallback): void; function cancelReminder(reminderId: number): Promise; @@ -56,6 +62,8 @@ declare namespace reminderAgent { * @since 7 * @syscap SystemCapability.Notification.ReminderAgent * @param callback Indicates the callback function. + * @deprecated since 9 + * @useinstead reminderAgentManager.getValidReminders */ function getValidReminders(callback: AsyncCallback>): void; function getValidReminders(): Promise>; @@ -66,6 +74,8 @@ declare namespace reminderAgent { * @since 7 * @syscap SystemCapability.Notification.ReminderAgent * @param callback Indicates the callback function. + * @deprecated since 9 + * @useinstead reminderAgentManager.cancelAllReminders */ function cancelAllReminders(callback: AsyncCallback): void; function cancelAllReminders(): Promise; @@ -77,6 +87,8 @@ declare namespace reminderAgent { * @syscap SystemCapability.Notification.ReminderAgent * @param slot Indicates the slot. * @param callback Indicates the callback function. + * @deprecated since 9 + * @useinstead reminderAgentManager.addNotificationSlot */ function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback): void; function addNotificationSlot(slot: NotificationSlot): Promise; @@ -88,6 +100,8 @@ declare namespace reminderAgent { * @syscap SystemCapability.Notification.ReminderAgent * @param slotType Indicates the type of the slot. * @param callback Indicates the callback function. + * @deprecated since 9 + * @useinstead reminderAgentManager.removeNotificationSlot */ function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void; function removeNotificationSlot(slotType: notification.SlotType): Promise; @@ -97,12 +111,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ActionButtonType */ export enum ActionButtonType { /** * Button for closing the reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE */ ACTION_BUTTON_TYPE_CLOSE = 0, @@ -110,6 +128,8 @@ declare namespace reminderAgent { * Button for snoozing the reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE */ ACTION_BUTTON_TYPE_SNOOZE = 1 } @@ -119,12 +139,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderType */ export enum ReminderType { /** * Countdown reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER */ REMINDER_TYPE_TIMER = 0, @@ -132,6 +156,8 @@ declare namespace reminderAgent { * Calendar reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_CALENDAR */ REMINDER_TYPE_CALENDAR = 1, @@ -139,6 +165,8 @@ declare namespace reminderAgent { * Alarm reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_ALARM */ REMINDER_TYPE_ALARM = 2 } @@ -148,12 +176,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ActionButton */ interface ActionButton { /** * Text on the button. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ActionButton.title */ title: string; @@ -161,6 +193,8 @@ declare namespace reminderAgent { * Button type. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ActionButton.type */ type: ActionButtonType; } @@ -171,12 +205,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.WantAgent */ interface WantAgent { /** * Name of the package redirected to when the reminder notification is clicked. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.WantAgent.pkgName */ pkgName: string; @@ -184,6 +222,8 @@ declare namespace reminderAgent { * Name of the ability that is redirected to when the reminder notification is clicked. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.WantAgent.abilityName */ abilityName: string; } @@ -193,12 +233,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.MaxScreenWantAgent */ 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 + * @deprecated since 9 + * @useinstead reminderAgentManager.MaxScreenWantAgent.pkgName */ pkgName: string; @@ -206,6 +250,8 @@ declare namespace reminderAgent { * 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 + * @deprecated since 9 + * @useinstead reminderAgentManager.MaxScreenWantAgent.abilityName */ abilityName: string; } @@ -215,12 +261,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest */ interface ReminderRequest { /** * Type of the reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.reminderType */ reminderType: ReminderType; @@ -229,6 +279,8 @@ declare namespace reminderAgent { * (The parameter is optional. Up to two buttons are supported). * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.actionButton */ actionButton?: [ActionButton?, ActionButton?]; @@ -236,6 +288,8 @@ declare namespace reminderAgent { * Information about the ability that is redirected to when the notification is clicked. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.wantAgent */ wantAgent?: WantAgent; @@ -244,6 +298,8 @@ declare namespace reminderAgent { * If the device is in use, a notification will be displayed. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.maxScreenWantAgent */ maxScreenWantAgent?: MaxScreenWantAgent; @@ -251,6 +307,8 @@ declare namespace reminderAgent { * Ringing duration. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.ringDuration */ ringDuration?: number; @@ -258,6 +316,8 @@ declare namespace reminderAgent { * Number of reminder snooze times. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.snoozeTimes */ snoozeTimes?: number; @@ -265,6 +325,8 @@ declare namespace reminderAgent { * Reminder snooze interval. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.timeInterval */ timeInterval?: number; @@ -272,6 +334,8 @@ declare namespace reminderAgent { * Reminder title. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.title */ title?: string; @@ -279,6 +343,8 @@ declare namespace reminderAgent { * Reminder content. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.content */ content?: string; @@ -286,6 +352,8 @@ declare namespace reminderAgent { * Content to be displayed when the reminder is expired. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.expiredContent */ expiredContent?: string; @@ -293,6 +361,8 @@ declare namespace reminderAgent { * Content to be displayed when the reminder is snoozing. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.snoozeContent */ snoozeContent?: string; @@ -300,6 +370,8 @@ declare namespace reminderAgent { * notification id. If there are reminders with the same ID, the later one will overwrite the earlier one. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.notificationId */ notificationId?: number; @@ -307,15 +379,23 @@ declare namespace reminderAgent { * Type of the slot used by the reminder. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequest.slotType */ slotType?: notification.SlotType; } + /** + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestCalendar + */ interface ReminderRequestCalendar extends ReminderRequest { /** * Reminder time. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestCalendar.dateTime */ dateTime: LocalDateTime; @@ -323,6 +403,8 @@ declare namespace reminderAgent { * Month in which the reminder repeats. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatMonths */ repeatMonths?: Array; @@ -330,6 +412,8 @@ declare namespace reminderAgent { * Date on which the reminder repeats. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatDays */ repeatDays?: Array; } @@ -339,12 +423,16 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestAlarm */ interface ReminderRequestAlarm extends ReminderRequest { /** * Hour portion of the reminder time. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestAlarm.hour */ hour: number; @@ -352,6 +440,8 @@ declare namespace reminderAgent { * minute portion of the remidner time. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestAlarm.minute */ minute: number; @@ -359,6 +449,8 @@ declare namespace reminderAgent { * Days of a week when the reminder repeates. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestAlarm.daysOfWeek */ daysOfWeek?: Array; } @@ -368,6 +460,8 @@ declare namespace reminderAgent { * * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer */ interface ReminderRequestTimer extends ReminderRequest { triggerTimeInSeconds: number; @@ -378,6 +472,8 @@ declare namespace reminderAgent { * value of year. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer.year */ year: number; @@ -385,6 +481,8 @@ declare namespace reminderAgent { * value of month. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer.month */ month: number; @@ -392,6 +490,8 @@ declare namespace reminderAgent { * value of day. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer.day */ day: number; @@ -399,6 +499,8 @@ declare namespace reminderAgent { * value of hour. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer.hour */ hour: number; @@ -406,6 +508,8 @@ declare namespace reminderAgent { * value of minute. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer.minute */ minute: number; @@ -413,6 +517,8 @@ declare namespace reminderAgent { * value of second. * @since 7 * @syscap SystemCapability.Notification.ReminderAgent + * @deprecated since 9 + * @useinstead reminderAgentManager.ReminderRequestTimer.second */ second?: number; } diff --git a/api/@ohos.reminderAgentManager.d.ts b/api/@ohos.reminderAgentManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b96875149f9c98207c5f5dee9f2d5c8fd1e62060 --- /dev/null +++ b/api/@ohos.reminderAgentManager.d.ts @@ -0,0 +1,484 @@ +/* + * 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 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 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @import reminderAgentManager from '@ohos.reminderAgentManager'; + */ +declare namespace reminderAgentManager { + /** + * Publishes a scheduled reminder. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @permission ohos.permission.PUBLISH_AGENT_REMINDER + * @param { ReminderRequest } reminderReq - Indicates the reminder instance to publish. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + */ + function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback): void; + + /** + * Publishes a scheduled reminder. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @permission ohos.permission.PUBLISH_AGENT_REMINDER + * @param { ReminderRequest } reminderReq - Indicates the reminder instance to publish. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @returns { Promise } The reminder id. + */ + function publishReminder(reminderReq: ReminderRequest): Promise; + + /** + * Cancels a reminder. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { number } reminderId - Indicates the reminder id. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + */ + function cancelReminder(reminderId: number, callback: AsyncCallback): void; + + /** + * Cancels a reminder. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { number } reminderId - Indicates the reminder id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @returns { Promise } The promise returned by the function. + */ + function cancelReminder(reminderId: number): Promise; + + /** + * Obtains all the valid reminders of current application. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { AsyncCallback> } callback - Indicates the callback function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + */ + function getValidReminders(callback: AsyncCallback>): void; + + /** + * Obtains all the valid reminders of current application. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @returns { Promise> } The promise returned by the function. + */ + function getValidReminders(): Promise>; + + /** + * Cancels all the reminders of current application. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + */ + function cancelAllReminders(callback: AsyncCallback): void; + + /** + * Cancels all the reminders of current application. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @returns { Promise } The promise returned by the function. + */ + function cancelAllReminders(): Promise; + + /** + * Add notification slot. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { NotificationSlot } slot - Indicates the slot. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + */ + function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback): void; + + /** + * Add notification slot. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { NotificationSlot } slot - Indicates the slot. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @returns { Promise } The promise returned by the function. + */ + function addNotificationSlot(slot: NotificationSlot): Promise; + + /** + * Deletes a created notification slot based on the slot type. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { notification.SlotType } slotType Indicates the type of the slot. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + */ + function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback): void; + + /** + * Deletes a created notification slot based on the slot type. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + * @param { notification.SlotType } slotType Indicates the type of the slot. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @returns { Promise } The promise returned by the function. + */ + function removeNotificationSlot(slotType: notification.SlotType): Promise; + + /** + * Declares action button type. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + export enum ActionButtonType { + /** + * Button for closing the reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + ACTION_BUTTON_TYPE_CLOSE = 0, + + /** + * Button for snoozing the reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + ACTION_BUTTON_TYPE_SNOOZE = 1 + } + + /** + * Declares reminder type. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + export enum ReminderType { + /** + * Countdown reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + REMINDER_TYPE_TIMER = 0, + + /** + * Calendar reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + REMINDER_TYPE_CALENDAR = 1, + + /** + * Alarm reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + REMINDER_TYPE_ALARM = 2 + } + + /** + * Action button information. The button will show on displayed reminder. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ActionButton { + /** + * Text on the button. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + title: string; + + /** + * Button type. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + type: ActionButtonType; + } + + /** + * Want agent information. + * It will switch to target ability when you click the displayed reminder. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface WantAgent { + /** + * Name of the package redirected to when the reminder notification is clicked. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + pkgName: string; + + /** + * Name of the ability that is redirected to when the reminder notification is clicked. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + abilityName: string; + } + + /** + * Max screen want agent information. + * + * @since 9 + * @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 9 + * @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 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + abilityName: string; + } + + /** + * Reminder Common information. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ReminderRequest { + /** + * Type of the reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + reminderType: ReminderType; + + /** + * Action button displayed on the reminder notification. + * (The parameter is optional. Up to two buttons are supported). + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + actionButton?: [ActionButton?, ActionButton?]; + + /** + * Information about the ability that is redirected to when the notification is clicked. + * @since 9 + * @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 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + maxScreenWantAgent?: MaxScreenWantAgent; + + /** + * Ringing duration. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + ringDuration?: number; + + /** + * Number of reminder snooze times. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + snoozeTimes?: number; + + /** + * Reminder snooze interval. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + timeInterval?: number; + + /** + * Reminder title. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + title?: string; + + /** + * Reminder content. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + content?: string; + + /** + * Content to be displayed when the reminder is expired. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + expiredContent?: string; + + /** + * Content to be displayed when the reminder is snoozing. + * @since 9 + * @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 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + notificationId?: number; + + /** + * Type of the slot used by the reminder. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + slotType?: notification.SlotType; + } + + interface ReminderRequestCalendar extends ReminderRequest { + /** + * Reminder time. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + dateTime: LocalDateTime; + + /** + * Month in which the reminder repeats. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + repeatMonths?: Array; + + /** + * Date on which the reminder repeats. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + repeatDays?: Array; + } + + /** + * Alarm reminder information. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ReminderRequestAlarm extends ReminderRequest { + /** + * Hour portion of the reminder time. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + hour: number; + + /** + * Minute portion of the reminder time. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + minute: number; + + /** + * Days of a week when the reminder repeates. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + daysOfWeek?: Array; + } + + /** + * CountDown reminder information. + * + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + interface ReminderRequestTimer extends ReminderRequest { + triggerTimeInSeconds: number; + } + + interface LocalDateTime { + /** + * Value of year. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + year: number; + + /** + * Value of month. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + month: number; + + /** + * Value of day. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + day: number; + + /** + * Value of hour. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + hour: number; + + /** + * Value of minute. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + minute: number; + + /** + * Value of second. + * @since 9 + * @syscap SystemCapability.Notification.ReminderAgent + */ + second?: number; + } +} +export default reminderAgentManager; diff --git a/api/@ohos.resourceManager.d.ts b/api/@ohos.resourceManager.d.ts index b4f2afb22a0ad1165a791f9c389f0479d3d7cd4c..6b43f6b7df4800e5af4c56aae260dcb8016aa389 100644 --- a/api/@ohos.resourceManager.d.ts +++ b/api/@ohos.resourceManager.d.ts @@ -15,7 +15,7 @@ import { RawFileDescriptor as _RawFileDescriptor } from './global/rawFileDescriptor'; import { Resource as _Resource } from './global/resource'; -import { AsyncCallback } from './basic'; +import { AsyncCallback as _AsyncCallback } from './basic'; /** * Provides resource related APIs. @@ -185,6 +185,15 @@ export class DeviceCapability { deviceType: DeviceType } +/** + * The ResourceManager callback. + * @since 6 + * @deprecated since 9 + */ + export interface AsyncCallback { + (err: Error, data: T): void; +} + /** * Obtains the ResourceManager object of the current application. * @@ -262,7 +271,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getStringValue(resource: Resource, callback: AsyncCallback): void; + getStringValue(resource: Resource, callback: _AsyncCallback): void; /** * Obtains string resources associated with a specified resource object in Promise mode. @@ -310,7 +319,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getStringArrayValue(resource: Resource, callback: AsyncCallback>): void; + getStringArrayValue(resource: Resource, callback: _AsyncCallback>): void; /** * Obtains the array of character strings corresponding to a specified resource object in Promise mode. @@ -357,7 +366,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001002 - If the resource not found by module resId. * @since 9 */ - getMediaContent(resource: Resource, callback: AsyncCallback): void; + getMediaContent(resource: Resource, callback: _AsyncCallback): void; /** * Obtains the content of the media file corresponding to a specified resource object in Promise mode. @@ -405,7 +414,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001002 - If the resource not found by module resId. * @since 9 */ - getMediaContentBase64(resource: Resource, callback: AsyncCallback): void; + getMediaContentBase64(resource: Resource, callback: _AsyncCallback): void; /** * Obtains the Base64 code of the image resource corresponding to the specified resource object in Promise mode. @@ -425,7 +434,7 @@ export interface ResourceManager { * @param callback Indicates the asynchronous callback used to return the obtained device capability. * @since 6 */ - getDeviceCapability(callback: AsyncCallback): void; + getDeviceCapability(callback: _AsyncCallback): void; /** * Obtains the device capability in Promise mode. @@ -442,7 +451,7 @@ export interface ResourceManager { * configuration. * @since 6 */ - getConfiguration(callback: AsyncCallback): void; + getConfiguration(callback: _AsyncCallback): void; /** * Obtains the device configuration in Promise mode. @@ -494,7 +503,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getPluralStringValue(resource: Resource, num: number, callback: AsyncCallback): void; + getPluralStringValue(resource: Resource, num: number, callback: _AsyncCallback): void; /** * Obtains the singular-plural character string represented by the resource object string corresponding to @@ -589,7 +598,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getStringByName(resName: string, callback: AsyncCallback): void; + getStringByName(resName: string, callback: _AsyncCallback): void; /** * Obtains string resources associated with a specified resource name in Promise mode. @@ -615,7 +624,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getStringArrayByName(resName: string, callback: AsyncCallback>): void; + getStringArrayByName(resName: string, callback: _AsyncCallback>): void; /** * Obtains the array of character strings corresponding to a specified resource name in Promise mode. @@ -640,7 +649,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001004 - If the resource not found by resName. * @since 9 */ - getMediaByName(resName: string, callback: AsyncCallback): void; + getMediaByName(resName: string, callback: _AsyncCallback): void; /** * Obtains the content of the media file corresponding to a specified resource name in Promise mode. @@ -665,7 +674,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001004 - If the resource not found by resName. * @since 9 */ - getMediaBase64ByName(resName: string, callback: AsyncCallback): void; + getMediaBase64ByName(resName: string, callback: _AsyncCallback): void; /** * Obtains the Base64 code of the image resource corresponding to the specified resource name in Promise mode. @@ -693,7 +702,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getPluralStringByName(resName: string, num: number, callback: AsyncCallback): void; + getPluralStringByName(resName: string, num: number, callback: _AsyncCallback): void; /** * Obtains the singular-plural character string represented by the name string corresponding to @@ -846,7 +855,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getStringValue(resId: number, callback: AsyncCallback): void; + getStringValue(resId: number, callback: _AsyncCallback): void; /** * Obtains string resources associated with a specified resource ID in Promise mode. @@ -872,7 +881,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getStringArrayValue(resId: number, callback: AsyncCallback>): void; + getStringArrayValue(resId: number, callback: _AsyncCallback>): void; /** * Obtains the array of character strings corresponding to a specified resource ID in Promise mode. @@ -901,7 +910,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001006 - If the resource re-ref too much. * @since 9 */ - getPluralStringValue(resId: number, num: number, callback: AsyncCallback): void; + getPluralStringValue(resId: number, num: number, callback: _AsyncCallback): void; /** * Obtains the singular-plural character string represented by the ID string corresponding to @@ -929,7 +938,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001002 - If the resource not found by resId. * @since 9 */ - getMediaContent(resId: number, callback: AsyncCallback): void; + getMediaContent(resId: number, callback: _AsyncCallback): void; /** * Obtains the content of the media file corresponding to a specified resource ID in Promise mode. @@ -954,7 +963,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001002 - If the resource not found by resId. * @since 9 */ - getMediaContentBase64(resId: number, callback: AsyncCallback): void; + getMediaContentBase64(resId: number, callback: _AsyncCallback): void; /** * Obtains the Base64 code of the image resource corresponding to the specified resource ID in Promise mode. @@ -977,7 +986,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001005 - If the resource not found by path. * @since 9 */ - getRawFileContent(path: string, callback: AsyncCallback): void; + getRawFileContent(path: string, callback: _AsyncCallback): void; /** * Obtains the raw file resource corresponding to the specified resource path in Promise mode. @@ -999,7 +1008,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001005 - If the resource not found by path. * @since 9 */ - getRawFd(path: string, callback: AsyncCallback): void; + getRawFd(path: string, callback: _AsyncCallback): void; /** * Obtains the raw file resource descriptor corresponding to the specified resource path in Promise mode. @@ -1021,7 +1030,7 @@ export interface ResourceManager { * @throws { BusinessError } 9001005 - If the resource not found by path. * @since 9 */ - closeRawFd(path: string, callback: AsyncCallback): void; + closeRawFd(path: string, callback: _AsyncCallback): void; /** * Obtains close raw file resource descriptor corresponding to the specified resource path in Promise mode. diff --git a/api/@ohos.resourceschedule.backgroundTaskManager.d.ts b/api/@ohos.resourceschedule.backgroundTaskManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2675ac47058f1b753160f070e4fd3578862ce350 --- /dev/null +++ b/api/@ohos.resourceschedule.backgroundTaskManager.d.ts @@ -0,0 +1,339 @@ +/* + * 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 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + */ +declare namespace backgroundTaskManager { + /** + * The info of delay suspend. + * + * @name DelaySuspendInfo + * @since 9 + * @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 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @param requestId Indicates the identifier of the delay request. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 9900001 - Caller information verification failed. + * @throws { BusinessError } 9900002 - Background task verification failed. + */ + function cancelSuspendDelay(requestId: number): void; + + /** + * Obtains the remaining time before an application enters the suspended state. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @param requestId Indicates the identifier of the delay request. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 9900001 - Caller information verification failed. + * @throws { BusinessError } 9900002 - Background task verification failed. + * @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 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + * @param reason Indicates the reason for delayed transition to the suspended state. + * @param callback The callback delay time expired. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 9900001 - Caller information verification failed. + * @throws { BusinessError } 9900002 - Background task verification failed. + * @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 9 + * @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. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 9800005 - Background task verification failed. + * @throws { BusinessError } 9800006 - Notification verification failed. + * @throws { BusinessError } 9800007 - Task storage failed. + */ + 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 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @param context app running context. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 9800005 - Background task verification failed. + * @throws { BusinessError } 9800006 - Notification verification failed. + * @throws { BusinessError } 9800007 - Task storage failed. + */ + function stopBackgroundRunning(context: Context, callback: AsyncCallback): void; + function stopBackgroundRunning(context: Context): Promise; + + /** + * Apply or unapply efficiency resources. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 18700001 - Caller information verification failed. + * @systemapi Hide this for inner system use. + */ + function applyEfficiencyResources(request: EfficiencyResourcesRequest): void; + + /** + * Reset all efficiency resources apply. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @systemapi Hide this for inner system use. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9800001 - Memory operation failed. + * @throws { BusinessError } 9800002 - Parcel operation failed. + * @throws { BusinessError } 9800003 - Inner transact failed. + * @throws { BusinessError } 9800004 - System service operation failed. + * @throws { BusinessError } 18700001 - Caller information verification failed. + */ + function resetAllEfficiencyResources(): void; + + /** + * Supported background mode. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + export enum BackgroundMode { + /** + * data transfer mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + DATA_TRANSFER = 1, + + /** + * audio playback mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + AUDIO_PLAYBACK = 2, + + /** + * audio recording mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + AUDIO_RECORDING = 3, + + /** + * location mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + LOCATION = 4, + + /** + * bluetooth interaction mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + BLUETOOTH_INTERACTION = 5, + + /** + * multi-device connection mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + MULTI_DEVICE_CONNECTION = 6, + + /** + * wifi interaction mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @systemapi Hide this for inner system use. + */ + WIFI_INTERACTION = 7, + + /** + * Voice over Internet Phone mode + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + * @systemapi Hide this for inner system use. + */ + VOIP = 8, + + /** + * background continuous calculate mode, for example 3D render. + * only supported in particular device + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + */ + TASK_KEEPING = 9, + } + + /** + * The type of resource. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @systemapi Hide this for inner system use. + */ + export enum ResourceType { + /** + * The cpu resource for not being suspended. + */ + CPU = 1, + + /** + * The resource for not being proxyed common_event. + */ + COMMON_EVENT = 1 << 1, + + /** + * The resource for not being proxyed timer. + */ + TIMER = 1 << 2, + + /** + * The resource for not being proxyed workscheduler. + */ + WORK_SCHEDULER = 1 << 3, + + /** + * The resource for not being proxyed bluetooth. + */ + BLUETOOTH = 1 << 4, + + /** + * The resource for not being proxyed gps. + */ + GPS = 1 << 5, + + /** + * The resource for not being proxyed audio. + */ + AUDIO = 1 << 6 + } + + /** + * The request of efficiency resources. + * + * @name EfficiencyResourcesRequest + * @since 9 + * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.EfficiencyResourcesApply + * @systemapi Hide this for inner system use. + */ + export interface EfficiencyResourcesRequest { + /** + * The set of resource types that app wants to apply. + */ + resourceTypes: number; + + /** + * True if the app begin to use, else false. + */ + isApply: boolean; + + /** + * The duration that the resource can be used most. + */ + timeOut: number; + + /** + * True if the apply action is persist, else false. Default value is false. + */ + isPersist?: boolean; + + /** + * True if apply action is for process, false is for package. Default value is false. + */ + isProcess?: boolean; + + /** + * The apply reason. + */ + reason: string; + } +} + +export default backgroundTaskManager; diff --git a/api/@ohos.resourceschedule.usageStatistics.d.ts b/api/@ohos.resourceschedule.usageStatistics.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..04bf7a289a72bed18c4540871efa795075147253 --- /dev/null +++ b/api/@ohos.resourceschedule.usageStatistics.d.ts @@ -0,0 +1,648 @@ +/* + * 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 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 BundleStatsInfo} instance and + * then returns it to you. + * + * @since 9 + */ +declare namespace usageStatistics { + + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @systemapi Hide this for inner system use. + */ + interface BundleStatsInfo { + /** + * The identifier of BundleStatsInfo. + */ + 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; + } + + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @systemapi Hide this for inner system use. + */ + interface HapFormInfo { + /** + * 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 + * @systemapi Hide this for inner system use. + */ + interface HapModuleInfo { + /** + * 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 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @systemapi Hide this for inner system use. + */ + interface DeviceEventStats { + /** + * The bundle name or system event name. + */ + name: string; + + /** + * The event id. + */ + eventId: number; + + /** + * The the event occurrence number. + */ + count: number; + } + + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + */ + interface BundleEvents { + /** + * The usage group of the application. + */ + appGroup?: number; + /** + * The bundle name. + */ + bundleName?: string; + /** + * The shortcut ID. + */ + indexOfLink?: string; + /** + * The class name. + */ + nameOfClass?: string; + /** + * The time when this state occurred, in milliseconds. + */ + eventOccurredTime?: number; + /** + * The event id. + */ + eventId?: number; + } + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @systemapi Hide this for inner system use. + */ + interface AppGroupCallbackInfo { + /* + * The usage old group of the application + */ + appOldGroup: number; + /* + * The usage new group of the application + */ + appNewGroup: 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 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @param bundleName Indicates the bundle name of the application to query. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @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 app 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 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000005 - Application is not installed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10100002 - Get Application group info failed. + * @return Returns the app group of the calling application. + */ + function queryAppGroup(callback: AsyncCallback): void; + function queryAppGroup(): 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 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param bundleName, name of the application. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000005 - Application is not installed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10100002 - Get Application group info failed. + * @return Returns the usage priority group of the calling application. + */ + function queryAppGroup(bundleName : string, callback: AsyncCallback): void; + function queryAppGroup(bundleName : string): Promise; + + /** + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @systemapi Hide this for inner system use. + */ + interface BundleStatsMap { + [key: string]: BundleStatsInfo; + } + + /** + * Queries usage information about each bundle within a specified period. + * + *

          This method queries usage information at the {@link #BY_OPTIMIZED} interval by default.

          + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the {@link BundleStatsMap} objects containing the usage information about each bundle. + */ + function queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback): void; + function queryBundleStatsInfos(begin: number, end: number): Promise; + + /** + * Declares interval type. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @systemapi Hide this for inner system use. + */ + 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 usage information about each bundle within a specified period at a specified interval. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param byInterval Indicates the interval at which the usage statistics are queried. + * The value can be {@link #BY_OPTIMIZED}, {@link #BY_DAILY}, + * {@link #BY_WEEKLY}, {@link #BY_MONTHLY}, or {@link #BY_ANNUALLY}. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the list of {@link BundleStatsInfo} objects containing the usage information about each bundle. + */ + function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback>): void; + function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise>; + + /** + * Queries state data of all bundles within a specified period identified by the start and end time. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the list of {@link BundleEvents} objects containing the state data of all bundles. + */ + function queryBundleEvents(begin: number, end: number, callback: AsyncCallback>): void; + function queryBundleEvents(begin: number, end: number): Promise>; + + /** + * Queries state data of the current bundle within a specified period. + * + * @since 9 + * @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. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the {@link BundleEvents} object Array containing the state data of the current bundle. + */ + function queryCurrentBundleEvents(begin: number, end: number, callback: AsyncCallback>): void; + function queryCurrentBundleEvents(begin: number, end: number): Promise>; + + /** + * Queries recently module usage records. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param maxNum Indicates max record number in result, max value is 1000, default value is 1000. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the {@link HapModuleInfo} object Array containing the usage data of the modules. + */ + function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback>): void; + function queryModuleUsageRecords(maxNum: number): Promise>; + + /** + * Queries recently module usage records. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the {@link HapModuleInfo} object Array containing the usage data of the modules. + */ + function queryModuleUsageRecords(callback: AsyncCallback>): void; + function queryModuleUsageRecords(): Promise>; + + /** + * Declares group type. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @systemapi Hide this for inner system use. + */ + export enum GroupType { + /** + * Indicates the alive group. + */ + ALIVE_GROUP = 10, + + /** + * Indicates the daily group. + */ + DAILY_GROUP = 20, + + /** + * Indicates the fixed group. + */ + FIXED_GROUP = 30, + + /** + * Indicates the rare group. + */ + RARE_GROUP = 40, + + /** + * Indicates the limit group. + */ + LIMITED_GROUP = 50, + + /** + * Indicates the never group. + */ + NEVER_GROUP = 60 + } + + /** + * Set app group by bundleName and number. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param bundleName, name of the application. + * @param newGroup, the group of the application whose name is bundleName. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10100001 - Application group operation repeated. + */ + function setAppGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback): void; + function setAppGroup(bundleName: string, newGroup: GroupType): Promise; + + /** + * Register callback to service. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param Callback, callback when application group change,return the AppGroupCallbackInfo. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10100001 - Application group operation repeated. + * @return Returns AppGroupCallbackInfo when the group of bundle changed. + */ + function registerAppGroupCallBack(groupCallback: Callback, callback: AsyncCallback): void; + function registerAppGroupCallBack(groupCallback: Callback): Promise; + + /** + * Unregister callback from service. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.AppGroup + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10100001 - Application group operation repeated. + */ + function unregisterAppGroupCallBack(callback: AsyncCallback): void; + function unregisterAppGroupCallBack(): Promise; + + /** + * Queries device event states data within a specified period identified by the start and end time. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the {@link DeviceEventStats} object Array containing the event states data. + */ + function queryDeviceEventStats(begin: number, end: number, callback: AsyncCallback>): void; + function queryDeviceEventStats(begin: number, end: number): Promise>; + + /** + * Queries app notification number within a specified period identified by the start and end time. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.UsageStatistics.App + * @permission ohos.permission.BUNDLE_ACTIVE_INFO + * @systemapi Hide this for inner system use. + * @param begin Indicates the start time of the query period, in milliseconds. + * @param end Indicates the end time of the query period, in milliseconds. + * @throws { BusinessError } 201 - Parameter error. + * @throws { BusinessError } 401 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 10000001 - Memory operation failed. + * @throws { BusinessError } 10000002 - Parcel operation failed. + * @throws { BusinessError } 10000003 - System service operation failed. + * @throws { BusinessError } 10000004 - IPC Communication failed. + * @throws { BusinessError } 10000006 - Get application info failed. + * @throws { BusinessError } 10000007 - Get system or actual time failed. + * @return Returns the {@link NotificationEventStats} object Array containing the event states data. + */ + function queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback>): void; + function queryNotificationEventStats(begin: number, end: number): Promise>; +} + +export default usageStatistics; \ No newline at end of file diff --git a/api/@ohos.workScheduler.d.ts b/api/@ohos.resourceschedule.workScheduler.d.ts similarity index 75% rename from api/@ohos.workScheduler.d.ts rename to api/@ohos.resourceschedule.workScheduler.d.ts index 67606bcf855368da4f795d6e192a9c62e91396a7..0bc914b45f66d2bb70bccebe07a2cb36d1138879 100644 --- a/api/@ohos.workScheduler.d.ts +++ b/api/@ohos.resourceschedule.workScheduler.d.ts @@ -1,277 +1,304 @@ -/* - * 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; - /** - * The parameters of the work. The value is only supported basic type(Number, String, Boolean). - */ - parameters?: {[key: string]: any}; - } - - /** - * 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 - } -} +/* + * 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; + /** + * The parameters of the work. The value is only supported basic type(Number, String, Boolean). + */ + parameters?: {[key: string]: any}; + } + + /** + * 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. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9700001 - Memory operation failed. + * @throws { BusinessError } 9700002 - Parcel operation failed. + * @throws { BusinessError } 9700003 - System service operation failed. + * @throws { BusinessError } 9700004 - Check workInfo failed. + * @throws { BusinessError } 9700005 - StartWork failed. + */ + function startWork(work: WorkInfo): void; + + /** + * 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. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9700001 - Memory operation failed. + * @throws { BusinessError } 9700002 - Parcel operation failed. + * @throws { BusinessError } 9700003 - System service operation failed. + * @throws { BusinessError } 9700004 - Check workInfo failed. + */ + function stopWork(work: WorkInfo, needCancel?: boolean): void; + + /** + * Obtains the work info of the wordId. + * + * @since 9 + * @syscap SystemCapability.ResourceSchedule.WorkScheduler + * @StageModelOnly + * @param workId The id of work. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9700001 - Memory operation failed. + * @throws { BusinessError } 9700002 - Parcel operation failed. + * @throws { BusinessError } 9700003 - System service operation failed. + * @throws { BusinessError } 9700004 - Check workInfo failed. + */ + 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 + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9700001 - Memory operation failed. + * @throws { BusinessError } 9700002 - Parcel operation failed. + * @throws { BusinessError } 9700003 - System service operation failed. + * @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 + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9700001 - Memory operation failed. + * @throws { BusinessError } 9700002 - Parcel operation failed. + * @throws { BusinessError } 9700003 - System service operation failed. + * @throws { BusinessError } 9700004 - Check workInfo failed. + */ + function stopAndClearWorks(): void; + + /** + * 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. + * @throws { BusinessError } 401 - Parameter error. + * @throws { BusinessError } 9700001 - Memory operation failed. + * @throws { BusinessError } 9700002 - Parcel operation failed. + * @throws { BusinessError } 9700003 - System service operation failed. + * @throws { BusinessError } 9700004 - Check workInfo failed. + * @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; \ No newline at end of file diff --git a/api/@ohos.rpc.d.ts b/api/@ohos.rpc.d.ts index c966c3c43dcb5ab389c85b38082760d2379f1a21..a2fe2513a3c4fc68886bbab908f5f3d278a2f61b 100644 --- a/api/@ohos.rpc.d.ts +++ b/api/@ohos.rpc.d.ts @@ -1486,7 +1486,7 @@ declare namespace rpc { * Writes an anonymous shared memory object to this {@link MessageSequence} object. * @param ashmem Anonymous shared memory object to wrote. * @throws { BusinessError } 401 - check param failed - * @throws { BusinessError } 1900009 - write data to message sequence failed + * @throws { BusinessError } 1900003 - write to ashmem failed * @since 9 */ writeAshmem(ashmem: Ashmem): void; @@ -1495,7 +1495,7 @@ declare namespace rpc { * Reads the anonymous shared memory object from this {@link MessageSequence} object. * @return Anonymous share object obtained. * @throws { BusinessError } 401 - check param failed - * @throws { BusinessError } 1900009 - write data to message sequence failed + * @throws { BusinessError } 1900004 - read from ashmem failed * @since 9 */ readAshmem(): Ashmem; @@ -1849,7 +1849,7 @@ declare namespace rpc { * @return Returns the interface descriptor. * @since 7 * @deprecated since 9 - * @useinstead ohos.rpc.IRemoteObject#getInterfaceDescriptor + * @useinstead ohos.rpc.IRemoteObject#getDescriptor */ getInterfaceDescriptor(): string; @@ -1862,7 +1862,7 @@ declare namespace rpc { * @throws { BusinessError } 1900008 - proxy or remote object is invalid * @since 9 */ - getInterfaceDescriptor(): string; + getDescriptor(): string; /** * Checks whether an object is dead. @@ -2082,10 +2082,9 @@ declare namespace rpc { * @return * Returns a simple boolean which is {@code true} if the operation succeeds; {{@code false} otherwise} when the function call is synchronous. * Returns a promise object with a boolean when the function call is asynchronous. - * @throws RemoteException Throws this exception if a remote service error occurs. * @since 9 */ - onRemoteRequestEx(code: number, data: MessageParcel, reply: MessageParcel, options: MessageOption): boolean | Promise; + onRemoteMessageRequest(code: number, data: MessageSequence, reply: MessageSequence, options: MessageOption): boolean | Promise; /** * Sets an entry for receiving requests. @@ -2752,6 +2751,7 @@ declare namespace rpc { * 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. + * @throws { BusinessError } 401 - check param failed * @throws { BusinessError } 1900001 - call mmap function failed * @since 9 */ @@ -2802,6 +2802,7 @@ declare namespace rpc { /** * Sets the protection level of the memory region to which the shared file is mapped. * @param protectionType Protection type to set. + * @throws { BusinessError } 401 - check param failed * @throws { BusinessError } 1900002 - os ioctl function failed * @since 9 */ @@ -2825,7 +2826,7 @@ declare namespace rpc { * @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. * @throws { BusinessError } 401 - check param failed - * @throws { BusinessError } 1900009 - write to ashmem failed + * @throws { BusinessError } 1900003 - write to ashmem failed * @since 9 */ writeAshmem(buf: number[], size: number, offset: number): void; @@ -2847,7 +2848,7 @@ declare namespace rpc { * @param offset Start position of the data to read in the memory region associated with this Ashmem object. * @return Data read. * @throws { BusinessError } 401 - check param failed - * @throws { BusinessError } 1900010 - read from ashmem failed + * @throws { BusinessError } 1900004 - read from ashmem failed * @since 9 */ readAshmem(size: number, offset: number): number[]; diff --git a/api/@ohos.runningLock.d.ts b/api/@ohos.runningLock.d.ts index d9365fbcf38354c149b12a47f207b70fa82fed55..84a763647c6568793b260e0c82fbaf692ec56629 100644 --- a/api/@ohos.runningLock.d.ts +++ b/api/@ohos.runningLock.d.ts @@ -13,16 +13,16 @@ * limitations under the License. */ -import {AsyncCallback} from './basic'; +import {AsyncCallback, BusinessError} from './basic'; /** * 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. + *

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

          {@link hold} 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 @@ -33,29 +33,67 @@ declare namespace runningLock { * Prevents the system from hibernating and sets the lock duration. * This method requires the ohos.permission.RUNNING_LOCK permission. * + * @permission ohos.permission.RUNNING_LOCK * @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 + * @deprecated since 9 + * @useinstead {@link RunningLock#hold} */ lock(timeout: number): void; + /** + * Prevents the system from hibernating and sets the lock duration. + * This method requires the ohos.permission.RUNNING_LOCK permission. + * + * @permission ohos.permission.RUNNING_LOCK + * @param {number} 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. + * @throws {BusinessError} 401 - If the timeout is not valid. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @since 9 + */ + hold(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 + * @deprecated since 9 + * @useinstead {@link RunningLock#isHolding} */ isUsed(): boolean; + /** + * 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. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @since 9 + */ + isHolding(): 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 + * @since 7 + * @deprecated since 9 + * @useinstead {@link RunningLock#unhold} */ unlock(): void; + + /** + * Release the {@link RunningLock} that prevents the system from hibernating. + * This method requires the ohos.permission.RUNNING_LOCK permission. + * + * @permission ohos.permission.RUNNING_LOCK + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @since 9 + */ + unhold(): void; } /** @@ -85,12 +123,28 @@ declare namespace runningLock { * Checks whether the specified {@link RunningLockType} is supported. * * @param type Indicates the specified {@link RunningLockType}. + * @param callback Indicates the callback function contains the result whether the specified + * {@link RunningLockType} is supported. * @return Returns true if the specified {@link RunningLockType} is supported; * returns false otherwise. * @since 7 + * @deprecated since 9 + * @useinstead {@link RunningLock#isSupported} */ function isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback): void; function isRunningLockTypeSupported(type: RunningLockType): Promise; + + /** + * Checks whether the specified {@link RunningLockType} is supported. + * + * @param {RunningLockType} type Indicates the specified {@link RunningLockType}. + * @return {boolean} Whether the specified {@link RunningLockType} is supported. + * @throws {BusinessError} 401 - If the type is not valid. + * @throws {BusinessError} 4900101 - If connecting to the service failed. + * @since 9 + */ + function isSupported(type: RunningLockType): boolean; + /** * Creates a {@link RunningLock} object. * @@ -101,11 +155,48 @@ declare namespace runningLock { * @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}. + * @param callback Indicates the callback contains the {@link RunningLock} object. * @return Returns the {@link RunningLock} object. * @permission ohos.permission.RUNNING_LOCK * @since 7 + * @deprecated since 9 + * @useinstead {@link RunningLock#create} */ function createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback): void; function createRunningLock(name: string, 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. + * + * @permission ohos.permission.RUNNING_LOCK + * @param {string} name Indicates the {@link RunningLock} name. A recommended name consists of the package or + * class name and a suffix. + * @param {RunningLockType} type Indicates the {@link RunningLockType}. + * @param {AsyncCallback)} callback Indicates the callback of {@link RunningLock} object. + * @throws {BusinessError} 401 - If the name, type or callback is not valid. + * @since 9 + */ + function create(name: string, type: RunningLockType, callback: AsyncCallback): void; + + /** + * 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. + * + * @permission ohos.permission.RUNNING_LOCK + * @param {string} name Indicates the {@link RunningLock} name. A recommended name consists of the package or + * class name and a suffix. + * @param {RunningLockType} type Indicates the {@link RunningLockType}. + * @return {Promise} The {@link RunningLock} object. + * @throws {BusinessError} 401 - If the name or type is not valid. + * @since 9 + */ + function create(name: string, type: RunningLockType): Promise; } export default runningLock; diff --git a/api/@ohos.systemParameterV9.d.ts b/api/@ohos.systemParameterV9.d.ts index a32bcb4fb5a93f3714b1abb6fa9e184fd9f3c2dd..b4fee996db64a70bcfa20c3875e4680f3a73981b 100755 --- a/api/@ohos.systemParameterV9.d.ts +++ b/api/@ohos.systemParameterV9.d.ts @@ -15,58 +15,6 @@ import { AsyncCallback, BusinessError } from './basic'; -/** - * Enumerates error code. - * - * @since 9 - */ -export enum SystemParameterErrorCode { - /** - * Input parameter is missing or invalid. - * - * @since 9 - */ - SYSPARAM_INVALID_INPUT = 401, - - /** - * System parameter can not be found.
          - * When getting system parameter values, if def value is specified, it will not return this error. - * - * @since 9 - */ - SYSPARAM_NOT_FOUND = 14700101, - - /** - * System parameter value is invalid.
          - * -

          When setting system parameters, the value length should not exceed 95 bytes.

          - * -

          And system parameter has three value types: string, integer and bool. - * if the value type is not matched, it will also return this error code.

          - * - * @since 9 - */ - SYSPARAM_INVALID_VALUE = 14700102, - - /** - * System permission operation permission denied.
          - *

          System parameter are system resources, each parameter is protected by DAC and MAC rules. - *

          Typical permission checking include:

          - * -

          systemapi: only system application can call system parameter related APIs

          - * -

          DAC: each system parameter has user and group owner with get, set permissions. - * Applications can only operate User/Group/Ownership matched system parameters.

          - * -

          MAC: each system parameter is also protected by SELinux labels.

          - * - * @since 9 - */ - SYSPARAM_PERMISSION_DENIED = 14700103, - - /** - * System internal error including out of memory, deadlock etc. - * - * @since 9 - */ - SYSPARAM_SYSTEM_ERROR = 14700104, -} - /** * The interface of system parameters class. * diff --git a/api/@ohos.telephony.call.d.ts b/api/@ohos.telephony.call.d.ts index a0a6b2abafeef8e2c88bb600337284ca92bd7a74..4a5bb01d2ffee37e95c3edb7fc75d60a42e64c89 100644 --- a/api/@ohos.telephony.call.d.ts +++ b/api/@ohos.telephony.call.d.ts @@ -154,6 +154,7 @@ declare namespace call { * Hangups the foreground call. * * @param callId Indicates the identifier of the call to hangup. + * @permission ohos.permission.ANSWER_CALL * @systemapi Hide this for inner system use. * @since 7 */ @@ -173,6 +174,7 @@ declare namespace call { * * @param callId Indicates the identifier of the call to reject. * @param options Indicates the text message to reject. + * @permission ohos.permission.ANSWER_CALL * @systemapi Hide this for inner system use. * @since 7 */ @@ -184,6 +186,7 @@ declare namespace call { * Rejects the incoming call without callId. * * @param options Indicates the text message to reject. + * @permission ohos.permission.ANSWER_CALL * @systemapi Hide this for inner system use. * @since 9 */ @@ -191,6 +194,7 @@ declare namespace call { function reject(options: RejectMessageOptions, callback: AsyncCallback): void; /** + * @permission ohos.permission.ANSWER_CALL * @systemapi Hide this for inner system use. * @since 7 */ @@ -198,6 +202,7 @@ declare namespace call { function holdCall(callId: number): Promise; /** + * @permission ohos.permission.ANSWER_CALL * @systemapi Hide this for inner system use. * @since 7 */ @@ -205,6 +210,7 @@ declare namespace call { function unHoldCall(callId: number): Promise; /** + * @permission ohos.permission.ANSWER_CALL * @systemapi Hide this for inner system use. * @since 7 */ @@ -240,6 +246,7 @@ declare namespace call { function getCallIdListForConference(callId: number): Promise>; /** + * @permission ohos.permission.GET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 7 */ @@ -247,6 +254,7 @@ declare namespace call { function getCallWaitingStatus(slotId: number): Promise; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 7 */ @@ -276,36 +284,42 @@ declare namespace call { function isInEmergencyCall(): Promise; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 7 */ function on(type: 'callDetailsChange', callback: Callback): void; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 7 */ function off(type: 'callDetailsChange', callback?: Callback): void; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ function on(type: 'callEventChange', callback: Callback): void; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ function off(type: 'callEventChange', callback?: Callback): void; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ function on(type: 'callDisconnectedCause', callback: Callback): void; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -316,19 +330,35 @@ declare namespace call { * * @param type Indicates the observer type. * @param callback Return the result of MMI code. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. * @systemapi Hide this for inner system use. * @since 9 */ function on(type: 'mmiCodeResult', callback: Callback): void; - /** - * Unobserve the result of MMI code - * - * @param type Indicates the observer type. - * @param callback Return the result of MMI code. - * @systemapi Hide this for inner system use. - * @since 9 - */ + /** + * Unobserve the result of MMI code + * + * @param type Indicates the observer type. + * @param callback Return the result of MMI code. + * @permission ohos.permission.SET_TELEPHONY_STATE + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. + * @systemapi Hide this for inner system use. + * @since 9 + */ function off(type: 'mmiCodeResult', callback?: Callback): void; /** @@ -346,6 +376,7 @@ declare namespace call { function separateConference(callId: number): Promise; /** + * @permission ohos.permission.GET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -353,6 +384,7 @@ declare namespace call { function getCallRestrictionStatus(slotId: number, type: CallRestrictionType): Promise; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -360,6 +392,7 @@ declare namespace call { function setCallRestriction(slotId: number, info: CallRestrictionInfo): Promise; /** + * @permission ohos.permission.GET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -367,6 +400,7 @@ declare namespace call { function getCallTransferInfo(slotId: number, type: CallTransferType): Promise; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -432,6 +466,7 @@ declare namespace call { function updateImsCallMode(callId: number, mode: ImsCallMode): Promise; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -439,6 +474,7 @@ declare namespace call { function enableImsSwitch(slotId: number): Promise; /** + * @permission ohos.permission.SET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -809,4 +845,4 @@ declare namespace call { } } -export default call; \ No newline at end of file +export default call; diff --git a/api/@ohos.telephony.data.d.ts b/api/@ohos.telephony.data.d.ts index 1ca3ce823f77aed38d4cfc72243670bd0c3022db..a562d690804057646804409fa2c69881e6cd3176 100644 --- a/api/@ohos.telephony.data.d.ts +++ b/api/@ohos.telephony.data.d.ts @@ -26,7 +26,6 @@ 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; @@ -34,10 +33,7 @@ declare namespace data { /** * Checks whether cellular data services are enabled. * - *

          Requires Permission: {@code ohos.permission.GET_NETWORK_INFO}. - * * @return Returns default cellular data slot id. - * @permission ohos.permission.GET_NETWORK_INFO * @since 9 */ function getDefaultCellularDataSlotIdSync(): number; @@ -199,4 +195,4 @@ declare namespace data { } } -export default data; \ No newline at end of file +export default data; diff --git a/api/@ohos.telephony.radio.d.ts b/api/@ohos.telephony.radio.d.ts index 4886f4aa2c83e2c853a7bb57198cc46771d4aa7e..75098eb1d8d1ad8dfcb9cc0692cfe73e88a2b686 100644 --- a/api/@ohos.telephony.radio.d.ts +++ b/api/@ohos.telephony.radio.d.ts @@ -67,6 +67,7 @@ declare namespace radio { /** * Proactively requests to update location information. * + * @permission ohos.permission.LOCATION * @param { number } [ slotId ] - indicates the card slot index number. * @param { AsyncCallback } callback - the callback of sendUpdateCellLocationRequest. * @systemapi @@ -78,6 +79,7 @@ declare namespace radio { /** * Proactively requests to update location information. * + * @permission ohos.permission.LOCATION * @param { number } [ slotId ] - indicates the card slot index number. * @returns { Promise } the promise returned by the function. * @systemapi @@ -305,6 +307,13 @@ declare namespace radio { * @param imsType Indicates the ims service type of the {@link ImsServiceType}. * @param callback including an instance of the {@link ImsRegInfo} class. * @permission ohos.permission.GET_TELEPHONY_STATE + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. * @systemapi Hide this for inner system use. * @since 9 */ @@ -320,6 +329,13 @@ declare namespace radio { * @param imsType Indicates the ims service type of the {@link ImsServiceType}. * @param callback including an instance of the {@link ImsRegInfo} class. * @permission ohos.permission.GET_TELEPHONY_STATE + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. * @systemapi Hide this for inner system use. * @since 9 */ @@ -328,6 +344,13 @@ declare namespace radio { /** * @permission ohos.permission.GET_TELEPHONY_STATE + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. * @systemapi Hide this for inner system use. * @since 9 */ @@ -835,7 +858,7 @@ declare namespace radio { IMS_UNREGISTERED, IMS_REGISTERED, } - + /** * @systemapi Hide this for inner system use. * @since 9 @@ -846,7 +869,7 @@ declare namespace radio { REGISTRATION_TECH_IWLAN, REGISTRATION_TECH_NR, } - + /** * @systemapi Hide this for inner system use. * @since 9 @@ -855,7 +878,7 @@ declare namespace radio { imsRegState: ImsRegState; imsRegTech: ImsRegTech; } - + /** * @systemapi Hide this for inner system use. * @since 9 diff --git a/api/@ohos.telephony.sim.d.ts b/api/@ohos.telephony.sim.d.ts index 7e3d87ff684255067e2e99fea96f472741cf0da1..0b269cb7ea9b20b97147d1b4647c38bf6611c96a 100644 --- a/api/@ohos.telephony.sim.d.ts +++ b/api/@ohos.telephony.sim.d.ts @@ -399,6 +399,7 @@ declare namespace sim { function updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise; /** + * @permission ohos.permission.GET_TELEPHONY_STATE * @systemapi Hide this for inner system use. * @since 8 */ @@ -434,6 +435,14 @@ declare namespace sim { * * @param slotId Indicates the card slot index number, * ranging from 0 to the maximum card slot index number supported by the device. + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. * @return Returns the opkey; returns an empty string if no SIM card is inserted or * no opkey matched. * @since 9 @@ -441,17 +450,25 @@ declare namespace sim { function getOpKey(slotId: number, callback: AsyncCallback): void; function getOpKey(slotId: number): Promise; - /** - * Obtains the opname 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. - * @return Returns the opname; returns an empty string if no SIM card is inserted or - * no opname matched. - * @since 9 - */ - function getOpName(slotId: number, callback: AsyncCallback): void; - function getOpName(slotId: number): Promise; + /** + * Obtains the opname 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. + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Parameter error. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 8300001 - Invalid parameter value. + * @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service. + * @throws {BusinessError} 8300003 - System internal error. + * @throws {BusinessError} 8300004 - Do not have sim card. + * @throws {BusinessError} 8300999 - Unknown error code. + * @return Returns the opname; returns an empty string if no SIM card is inserted or + * no opname matched. + * @since 9 + */ + function getOpName(slotId: number, callback: AsyncCallback): void; + function getOpName(slotId: number): Promise; /** * @systemapi Hide this for inner system use. diff --git a/api/@ohos.thermal.d.ts b/api/@ohos.thermal.d.ts index eb80bfa5f9ba464d9a2273216255a2e2307ecd13..566c146fb3fd033e7a22787c7b69a9838227ffac 100644 --- a/api/@ohos.thermal.d.ts +++ b/api/@ohos.thermal.d.ts @@ -13,13 +13,13 @@ * limitations under the License. */ -import { AsyncCallback, Callback } from './basic'; +import {AsyncCallback, BusinessError, Callback} from './basic'; /** - * Provides thermal level-related callback and query APIs to obtain the information required for + * 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. + * {@link registerThermalLevelCallback}: subscribes to callbacks of thermal level changes. + * {@link getLevel}: obtains the thermal level of the system in real time. * * @syscap SystemCapability.PowerManager.ThermalManager * @since 8 @@ -44,50 +44,85 @@ declare namespace thermal { */ WARM = 2, /** - * The device is heating up. You need to stop all imperceptible services and downgrade + * 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 + * 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 + * 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 + * 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 + * @deprecated since 9 + * @useinstead {@link thermal#registerThermalLevelCallback} */ function subscribeThermalLevel(callback: AsyncCallback): void; + /** + * Registers to callbacks of thermal level changes. + * + * @param {Callback} callback Callback of thermal level changes. + * @throws {BusinessError} 401 - If callback is not valid. + * @throws {BusinessError} 4800101 If connecting to the service failed. + * @since 9 + */ + function registerThermalLevelCallback(callback: Callback): void; + /** * Unsubscribes from the callbacks of thermal level changes. * * @param callback Callback of thermal level changes. - * @since 8 + * @deprecated since 9 + * @useinstead {@link thermal#unregisterThermalLevelCallback} */ function unsubscribeThermalLevel(callback?: AsyncCallback): void; + /** + * Unregisters from the callbacks of thermal level changes. + * + * @param {Callback} callback Callback of thermal level changes. + * @throws {BusinessError} 401 - If callback is not valid. + * @throws {BusinessError} 4800101 If connecting to the service failed. + * @since 9 + */ + function unregisterThermalLevelCallback(callback?: Callback): void; + /** * Obtains the current thermal level. * * @return Returns the thermal level. * @since 8 + * @deprecated since 9 + * @useinstead {@link thermal#getLevel} */ function getThermalLevel(): ThermalLevel; + + /** + * Obtains the current thermal level. + * + * @return {ThermalLevel} The thermal level. + * @throws {BusinessError} 4800101 If connecting to the service failed. + * @since 9 + */ + function getLevel(): ThermalLevel; } export default thermal; diff --git a/api/@ohos.uri.d.ts b/api/@ohos.uri.d.ts index 12b6b2230612efcc9d18be077fbbb47c71922e9a..7778407067e1e30e73502e61ecfecf91e9c0add9 100644 --- a/api/@ohos.uri.d.ts +++ b/api/@ohos.uri.d.ts @@ -1,5 +1,5 @@ /* -* Copyright (c) 2021 Huawei Device Co., Ltd. +* 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 @@ -21,10 +21,18 @@ * @permission N/A */ declare namespace uri { + + /** + * URI Represents a Uniform Resource Identifier (URI) reference. + * @name URI + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ class URI { /** * URI constructor, which is used to instantiate a URI object. * uri: Constructs a URI by parsing a given string. + * @throws {BusinessError} 401 - if the input parameters are invalid. */ constructor(uri: string); @@ -34,17 +42,29 @@ declare namespace uri { * @syscap SystemCapability.Utils.Lang * @return Returns the serialized URI as a string. */ - toString(): string + toString(): string; /** - * Tests whether this URI is equivalent to other URI objects. + * Check whether this URI is equivalent to other URI objects. * @since 8 + * @deprecated since 9 + * @useinstead ohos.uri.URI.equalsTo * @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; + /** + * Check whether this URI is equivalent to other URI objects. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param other URI object to be compared + * @return boolean Tests whether this URI is equivalent to other URI objects. + * @throws {BusinessError} 10200002 - The type of other must be URI. + */ + equalsTo(other: URI): boolean; + /** * Indicates whether this URI is an absolute URI. * @since 8 diff --git a/api/@ohos.url.d.ts b/api/@ohos.url.d.ts index 0f1f6b95631d6cac6f6eb2eb2b56e696b7553619..80d25e6c6d6dafe21bd029c13420a3873ad7bc2f 100644 --- a/api/@ohos.url.d.ts +++ b/api/@ohos.url.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -20,8 +20,15 @@ * @import import url from '@ohos.url'; * @permission N/A */ - declare namespace url { + /** + * The URLSearchParams interface defines some practical methods to process URL query strings. + * @name URLSearchParams + * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams + * @syscap SystemCapability.Utils.Lang + */ class URLSearchParams { /** * A parameterized constructor used to create an URLSearchParams instance. @@ -30,12 +37,16 @@ declare namespace url { * The input parameter is the object list. * The input parameter is a character string. * The input parameter is the URLSearchParams object. + * @deprecated since 9 + * @useinstead ohos.url.URLParams.constructor */ constructor(init?: string[][] | Record | string | URLSearchParams); /** * Appends a specified key/value pair as a new search parameter. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.append * @syscap SystemCapability.Utils.Lang * @param name Key name of the search parameter to be inserted. * @param value Values of search parameters to be inserted. @@ -45,16 +56,20 @@ declare namespace url { /** * Deletes the given search parameter and its associated value,from the list of all search parameters. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.delete * @syscap SystemCapability.Utils.Lang - * @param Name of the key-value pair to be deleted. + * @param name 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 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.getAll * @syscap SystemCapability.Utils.Lang - * @param Name Specifies the name of a key value. + * @param name Specifies the name of a key value. * @return string[] Returns all key-value pairs with the specified name. */ getAll(name: string): string[]; @@ -63,14 +78,18 @@ declare namespace url { * 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 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.entries * @syscap SystemCapability.Utils.Lang * @return Returns an iterator for ES6. */ - entries(): IterableIterator<[string, string]>; + entries(): IterableIterator<[string, string]>; /** * Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.forEach * @syscap SystemCapability.Utils.Lang * @param value Current traversal key value. * @param key Indicates the name of the key that is traversed. @@ -82,6 +101,8 @@ declare namespace url { /** * Returns the first value associated to the given search parameter. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.get * @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. @@ -91,6 +112,8 @@ declare namespace url { /** * Returns a Boolean that indicates whether a parameter with the specified name exists. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.has * @syscap SystemCapability.Utils.Lang * @param name Specifies the name of a key-value pair. * @return Returns a Boolean value that indicates whether a found @@ -103,6 +126,8 @@ declare namespace url { * deletes the others. If the search parameter doesn't exist, this * method creates it. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.set * @syscap SystemCapability.Utils.Lang * @param name Key name of the parameter to be set. * @param value Indicates the parameter value to be set. @@ -112,6 +137,8 @@ declare namespace url { /** * Sort all key/value pairs contained in this object in place and return undefined. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.sort * @syscap SystemCapability.Utils.Lang */ sort(): void; @@ -119,6 +146,8 @@ declare namespace url { /** * Returns an iterator allowing to go through all keys contained in this object. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.keys * @syscap SystemCapability.Utils.Lang * @return Returns an ES6 Iterator over the names of each name-value pair. */ @@ -127,6 +156,8 @@ declare namespace url { /** * Returns an iterator allowing to go through all values contained in this object. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.values * @syscap SystemCapability.Utils.Lang * @return Returns an ES6 Iterator over the values of each name-value pair. */ @@ -136,6 +167,8 @@ declare namespace url { * Returns an iterator allowing to go through all key/value * pairs contained in this object. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.[Symbol.iterator] * @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. @@ -145,21 +178,193 @@ declare namespace url { /** * Returns a query string suitable for use in a URL. * @since 7 + * @deprecated since 9 + * @useinstead ohos.url.URLParams.toString * @syscap SystemCapability.Utils.Lang * @return Returns a search parameter serialized as a string, percent-encoded if necessary. */ toString(): string; } - class URL { + /** + * The URLParams interface defines some practical methods to process URL query strings. + * @name URLParams + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + class URLParams { + /** + * 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. + * @since 9 + * @throws {BusinessError} 401 - The type of init must be string two-dimensional array or object list + * or string or URLSearchParams object. + */ + constructor(init?: string[][] | Record | string | URLSearchParams); + + /** + * Appends a specified key/value pair as a new search parameter. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param name Key name of the search parameter to be inserted. + * @param value Values of search parameters to be inserted. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + append(name: string, value: string): void; + + /** + * Deletes the given search parameter and its associated value,from the list of all search parameters. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param name Name of the key-value pair to be deleted. + * @throws {BusinessError} 401 - The type of name must be string. + */ + delete(name: string): void; + /** + * Returns all key-value pairs associated with a given search parameter as an array. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param name Specifies the name of a key value. + * @return string[] Returns all key-value pairs with the specified name. + * @throws {BusinessError} 401 - The type of name must be string. + */ + 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 9 + * @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 9 + * @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 + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + forEach(callbackfn: (value: string, key: string, searchParams: this) => void, thisArg?: Object): void; + + /** + * Returns the first value associated to the given search parameter. + * @since 9 + * @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. + * @throws {BusinessError} 401 - The type of name must be string. + */ + get(name: string): string | null; + + /** + * Returns a Boolean that indicates whether a parameter with the specified name exists. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param name Specifies the name of a key-value pair. + * @return Returns a Boolean value that indicates whether a found + * @throws {BusinessError} 401 - The type of name must be string. + */ + 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 9 + * @syscap SystemCapability.Utils.Lang + * @param name Key name of the parameter to be set. + * @param value Indicates the parameter value to be set. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + set(name: string, value: string): void; + + /** + * Sort all key/value pairs contained in this object in place and return undefined. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + sort(): void; + + /** + * Returns an iterator allowing to go through all keys contained in this object. + * @since 9 + * @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 9 + * @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 9 + * @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 9 + * @syscap SystemCapability.Utils.Lang + * @return Returns a search parameter serialized as a string, percent-encoded if necessary. + */ + toString(): string; + } + + /** + * The interface of URL is used to parse, construct, normalize, and encode URLs. + * @name URL + * @since 7 + * @syscap SystemCapability.Utils.Lang + */ + 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. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.URL.constructor */ constructor(url: string, base?: string | URL); + /** + * URL constructor, which is used to instantiate a URL object. + * @since 9 + */ + constructor(); + + /** + * Check the validity of parameters + * 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200002 - Invalid url string. + */ + static parseURL(url: string, base?: string | URL): URL; + /** * Returns the serialized URL as a string. * @since 7 diff --git a/api/@ohos.usb.d.ts b/api/@ohos.usb.d.ts index 00588468d50fb21fe16de0c73e33a267a6d3f450..fce6f34e612ec766ea826a05bc9f240b69fe497c 100644 --- a/api/@ohos.usb.d.ts +++ b/api/@ohos.usb.d.ts @@ -13,6 +13,10 @@ * limitations under the License. */ +/** + * @deprecated since 9 + * @useinstead ohos.usbV9 + */ declare namespace usb { /** * Obtains the USB device list. diff --git a/api/@ohos.usbV9.d.ts b/api/@ohos.usbV9.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ff0ebbe45e5789a3333a8b54d1d50ab7f1c5faf --- /dev/null +++ b/api/@ohos.usbV9.d.ts @@ -0,0 +1,939 @@ +/* + * 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. + */ + +/** + * This module provides the capability of manage USB device. + * @namespace usbV9 + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ +declare namespace usbV9 { + /** + * Obtains the USB device list. + * + * @return Returns the {@link USBDevice} list. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @throws {BusinessError} 14400001 - USB Device access denied. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function hasRight(deviceName: string): boolean; + + /** + * Requests the permission for a given application to access the USB device. + * + * @param deviceName Device name defined by {@link USBDevice.name}. + * @return Returns **true** if the device access permissions are granted; return **false** otherwise. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function requestRight(deviceName: string): Promise; + + /** + * Remove the permission for a given application to access the USB device. + * + * @param deviceName Device name defined by {@link USBDevice.name}. + * @return Returns **true** if the device access permissions are removed; return **false** otherwise. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function removeRight(deviceName: string): boolean; + + /** + * Add device access permission. + * + * @param bundleName refers to application that require access permissions. + * @param deviceName Device name defined by {@link USBDevice.name}. + * @return Returns the boolean value to indicate whether the permission is granted. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function addRight(bundleName: string, deviceName: string): boolean; + + /** + * Converts the string descriptor of a given USB function list to a numeric mask combination. + * + * @param funcs Descriptor of the supported function list. + * @return Returns the numeric mask combination of the function list. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function usbFunctionsFromString(funcs: string): number; + + /** + * Converts the numeric mask combination of a given USB function list to a string descriptor. + * + * @param funcs Numeric mask combination of the function list. + * @return Returns the string descriptor of the supported function list. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function usbFunctionsToString(funcs: FunctionType): string; + + /** + * Sets the current USB function list in Device mode. + * + * @param funcs Numeric mask combination of the supported function list. + * @return Returns **true** if the setting is successful; returns **false** otherwise. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function setCurrentFunctions(funcs: FunctionType): Promise; + + /** + * Obtains the numeric mask combination for the current USB function list in Device mode. + * + * @return Returns the numeric mask combination for the current USB function list in {@link FunctionType}. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function getCurrentFunctions(): FunctionType; + + /* usb port functions begin */ + /** + * Obtains the {@link USBPort} list. + * + * @return Returns the {@link USBPort} list. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function getPorts(): Array; + + /** + * Gets the mask combination for the supported mode list of the specified {@link USBPort}. + * + * @return Returns the mask combination for the supported mode list in {@link PortModeType}. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function getSupportedModes(portId: number): PortModeType; + + /** + * Sets the role types supported by the specified {@link USBPort}, which can be powerRole (for charging) and dataRole (for data transfer). + * + * @param portId Unique ID of the port. + * @param powerRole Charging role defined by {@link PowerRoleType}. + * @param dataRole Data role defined by {@link DataRoleType}. + * @return Returns the supported role type. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @systemapi + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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. + * @throws {BusinessError} 401 - The parameter types do not match or parameter is not specified. + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + 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}. + * + * @typedef USBEndpoint + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + interface USBEndpoint { + /** + * Endpoint address + * + * @since 9 + */ + address: number; + + /** + * Endpoint attributes + * + * @since 9 + */ + attributes: number; + + /** + * Endpoint interval + * + * @since 9 + */ + interval: number; + + /** + * Maximum size of data packets on the endpoint + * + * @since 9 + */ + maxPacketSize: number; + + /** + * Endpoint direction + * + * @since 9 + */ + direction: USBRequestDirection; + + /** + * Endpoint number + * + * @since 9 + */ + number: number; + + /** + * Endpoint type + * + * @since 9 + */ + type: number; + + /** + * Unique ID defined by {@link USBInterface.id}, which indicates the interface to which the endpoint belongs + * + * @since 9 + */ + interfaceId: number; + } + + + /** + * Represents a USB interface. One USBconfig {@link USBConfig} can contain multiple **USBInterface** instances, each providing a specific function. + * + * @typedef USBInterface + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + interface USBInterface { + /** + * Unique ID of the USB interface + * + * @since 9 + */ + id: number; + + /** + * Interface protocol + * + * @since 9 + */ + protocol: number; + + /** + * Device type + * + * @since 9 + */ + clazz: number; + + /** + * Device subclass + * + * @since 9 + */ + subClass: number; + + /** + * Alternating between descriptors of the same USB interface + * + * @since 9 + */ + alternateSetting: number; + + /** + * Interface name + * + * @since 9 + */ + name: string; + + /** + * {@link USBEndpoint} that belongs to the USB interface + * + * @since 9 + */ + endpoints: Array; + } + + /** + * USB configuration. One {@link USBDevice} can contain multiple USBConfig instances. + * + * @typedef USBConfig + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + interface USBConfig { + /** + * Unique ID of the USB configuration + * + * @since 9 + * + * + */ + id: number; + + /** + * Configuration attributes + * + * @since 9 + */ + attributes: number; + + /** + * Maximum power consumption, in mA + * + * @since 9 + */ + maxPower: number; + + /** + * Configuration name, which can be left empty + * + * @since 9 + */ + name: string; + + /** + * Support for remote wakeup + * + * @since 9 + */ + isRemoteWakeup: boolean; + + /** + * Support for independent power supplies + * + * @since 9 + */ + isSelfPowered: boolean; + + /** + * Supported interface attributes defined by {@link USBInterface} + * + * @since 9 + */ + interfaces: Array; + } + + /** + * Represents a USB device. + * + * @typedef USBDevice + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + interface USBDevice { + /** + * Bus address + * + * @since 9 + */ + busNum: number; + /** + * Device address + * + * @since 9 + */ + devAddress: number; + /** + * Device SN + * + * @since 9 + */ + serial: string; + /** + * Device name + * + * @since 9 + */ + name: string; + /** + * Device manufacturer + * + * @since 9 + */ + manufacturerName: string; + /** + * Product information + * + * @since 9 + */ + productName: string; + /** + * Product version + * + * @since 9 + */ + version: string; + /** + * Vendor ID + * + * @since 9 + */ + vendorId: number; + /** + * Product ID + * + * @since 9 + */ + productId: number; + /** + * Device class + * + * @since 9 + */ + clazz: number; + /** + * Device subclass + * + * @since 9 + */ + subClass: number; + /** + * Device protocol code + * + * @since 9 + */ + protocol: number; + /** + * Device configuration descriptor information defined by {@link USBConfig} + * + * @since 9 + */ + configs: Array; + } + + /** + * Represents a USB device pipe, which is used to determine the USB device. + * + * @typedef USBDevicePipe + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + interface USBDevicePipe { + /** + * Bus address. + * + * @since 9 + */ + busNum: number; + /** + * Device address + * + * @since 9 + */ + devAddress: number; + } + + /** + * Enumerates power role types. + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @systemapi + * @since 9 + */ + export enum PowerRoleType { + /** + * None + * + * @since 9 + */ + NONE = 0, + /** + * External power supply + * + * @since 9 + */ + SOURCE = 1, + /** + * Internal power supply + * + * @since 9 + */ + SINK = 2 + } + + /** + * Enumerates data role types. + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @systemapi + * @since 9 + */ + export enum DataRoleType { + /** + * None + * + * @since 9 + */ + NONE = 0, + /** + * Host mode + * + * @since 9 + */ + HOST = 1, + /** + * Device mode + * + * @since 9 + */ + DEVICE = 2 + } + + /** + * Enumerates port mode types + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @systemapi + * @since 9 + */ + export enum PortModeType { + /** + * None + * + * @since 9 + */ + NONE = 0, + /** + * Upstream facing port, which functions as the sink of power supply + * + * @since 9 + */ + UFP = 1, + /** + * Downstream facing port, which functions as the source of power supply + * + * @since 9 + */ + DFP = 2, + /** + * Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently. + * + * @since 9 + */ + DRP = 3, + /** + * Not supported currently + * + * @since 9 + */ + NUM_MODES = 4 + } + + /** + * Enumerates USB device port roles. + * + * @typedef USBPortStatus + * @syscap SystemCapability.USB.USBManager + * @systemapi + * @since 9 + */ + interface USBPortStatus { + /** + * USB mode + * + * @since 9 + */ + currentMode: number; + + /** + * Power role + * + * @since 9 + */ + currentPowerRole: number; + + /** + * Data role + * + * @since 9 + */ + currentDataRole: number; + } + + /** + * Represents a USB device port. + * + * @typedef USBPort + * @syscap SystemCapability.USB.USBManager + * @systemapi + * @since 9 + */ + interface USBPort { + /** + * Unique ID of the USB port + * + * @since 9 + */ + id: number; + + /** + * Mask combination for the supported mode list of the USB port + * + * @since 9 + */ + supportedModes: PortModeType; + + /** + * USB port role defined by {@link USBPortStatus} + * + * @since 9 + */ + status: USBPortStatus; + } + + /** + * Represents control transfer parameters. + * + * @typedef USBControlParams + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + interface USBControlParams { + /** + * Request type + * + * @since 9 + */ + request: number; + /** + * Request target type + * + * @since 9 + */ + target: USBRequestTargetType; + /** + * Control request type + * + * @since 9 + */ + reqType: USBControlRequestType; + /** + * Request parameter value + * + * @since 9 + */ + value: number; + /** + * Index of the parameter value + * + * @since 9 + */ + index: number; + /** + * Data written to or read from the buffer + * @since 9 + */ + data: Uint8Array; + } + + /** + * Enumerates USB request target types. + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + export enum USBRequestTargetType { + /** + * USB device + * + * @since 9 + */ + USB_REQUEST_TARGET_DEVICE = 0, + /** + * USB interface + * + * @since 9 + */ + USB_REQUEST_TARGET_INTERFACE = 1, + /** + * Endpoint + * + * @since 9 + */ + USB_REQUEST_TARGET_ENDPOINT = 2, + /** + * Others + * + * @since 9 + */ + USB_REQUEST_TARGET_OTHER = 3 + } + + /** + * Enumerates control request types. + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + export enum USBControlRequestType { + /** + * Standard + * + * @since 9 + */ + USB_REQUEST_TYPE_STANDARD = 0, + /** + * Class + * + * @since 9 + */ + USB_REQUEST_TYPE_CLASS = 1, + /** + * Vendor + * + * @since 9 + */ + USB_REQUEST_TYPE_VENDOR = 2 + } + + /** + * Enumerates request directions. + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @since 9 + */ + export enum USBRequestDirection { + /** + * Request for writing data from the host to the device + * + * @since 9 + */ + USB_REQUEST_DIR_TO_DEVICE = 0, + /** + * Request for reading data from the device to the host + * + * @since 9 + */ + USB_REQUEST_DIR_FROM_DEVICE = 0x80 + } + + /** + * Enumerates function modes. + * + * @enum { number } + * @syscap SystemCapability.USB.USBManager + * @systemapi + * @since 9 + */ + export enum FunctionType { + /** + * None + * + * @since 9 + */ + NONE = 0, + /** + * Serial port device + * + * @since 9 + */ + ACM = 1, + /** + * Ethernet port device + * + * @since 9 + */ + ECM = 2, + /** + * HDC device + * + * @since 9 + */ + HDC = 4, + /** + * MTP device + * + * @since 9 + */ + MTP = 8, + /** + * PTP device + * + * @since 9 + */ + PTP = 16, + /** + * RNDIS device + * + * @since 9 + */ + RNDIS = 32, + /** + * MIDI device + * + * @since 9 + */ + MIDI = 64, + /** + * Audio source device + * + * @since 9 + */ + AUDIO_SOURCE = 128, + /** + * NCM device + * + * @since 9 + */ + NCM = 256 + } + +} + +export default usbV9; diff --git a/api/@ohos.util.ArrayList.d.ts b/api/@ohos.util.ArrayList.d.ts index ac7174e4977125fb5714fad3183010d4622794f7..abeeada5a68a1507a0672b45ffded75669fe5d2d 100644 --- a/api/@ohos.util.ArrayList.d.ts +++ b/api/@ohos.util.ArrayList.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The ArrayList's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -29,6 +31,7 @@ declare class ArrayList { * 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. + * @throws { BusinessError } 10200011 - The add method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -39,7 +42,9 @@ declare class ArrayList { * 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 + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 10200011 - The insert method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -48,6 +53,7 @@ declare class ArrayList { * 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 + * @throws { BusinessError } 10200011 - The has method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -57,6 +63,7 @@ declare class ArrayList { * 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. + * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -66,7 +73,9 @@ declare class ArrayList { * 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 + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -77,6 +86,7 @@ declare class ArrayList { * 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 + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -86,6 +96,7 @@ declare class ArrayList { * or -1 if the arraylist does not contain the element. * @param element element to find * @return the number type + * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -94,8 +105,9 @@ declare class ArrayList { * 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 + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 10200011 - The removeByRange method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -109,11 +121,13 @@ declare class ArrayList { * @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 + * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList) => T, - thisArg?: Object): void; + 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 @@ -123,6 +137,8 @@ declare class ArrayList { * @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 + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -137,6 +153,8 @@ declare class ArrayList { * @param firstValue (Optional) previous element * @param secondValue (Optional) next elements * If this parameter is empty, it will default to ASCII sorting + * @throws { BusinessError } 10200011 - The sort method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -145,8 +163,10 @@ declare class ArrayList { * 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 + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 10200011 - The subArrayList method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -154,6 +174,7 @@ declare class ArrayList { /** * Removes all of the elements from this arraylist.The arraylist will * be empty after this call returns.length becomes 0 + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -161,6 +182,7 @@ declare class ArrayList { /** * Returns a shallow copy of this instance. (The elements themselves are not copied.) * @return this arraylist instance + * @throws { BusinessError } 10200011 - The clone method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -168,6 +190,7 @@ declare class ArrayList { /** * returns the capacity of this arraylist * @return the number type + * @throws { BusinessError } 10200011 - The getCapacity method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -175,6 +198,7 @@ declare class ArrayList { /** * convert arraylist to array * @return the Array type + * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -182,6 +206,7 @@ declare class ArrayList { /** * Determine whether arraylist is empty and whether there is an element * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -189,18 +214,22 @@ declare class ArrayList { /** * 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 + * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ increaseCapacityTo(newCapacity: number): void; /** * Limit the capacity to the current length + * @throws { BusinessError } 10200011 - The trimToCurrentLength method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ trimToCurrentLength(): void; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.Deque.d.ts b/api/@ohos.util.Deque.d.ts index b8b284b44a2d6abcc82c9f3f845a7daf743870cf..15c3906eab60e8d71b7331275108d1fe3432308a 100644 --- a/api/@ohos.util.Deque.d.ts +++ b/api/@ohos.util.Deque.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The Deque's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -28,6 +30,7 @@ declare class Deque { /** * Inserts an element into the deque header. * @param element to be appended to this deque + * @throws { BusinessError } 10200011 - The insertFront method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -35,6 +38,7 @@ declare class Deque { /** * Inserting an element at the end of a deque * @param element to be appended to this deque + * @throws { BusinessError } 10200011 - The insertEnd method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -43,6 +47,7 @@ declare class Deque { * 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 + * @throws { BusinessError } 10200011 - The has method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -50,6 +55,7 @@ declare class Deque { /** * Obtains the header element of a deque. * @return the T type + * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -57,7 +63,7 @@ declare class Deque { /** * Obtains the end element of a deque. * @return the T type - * @throws an exception if the queue is empty + * @throws { BusinessError } 10200011 - The getLast method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -65,7 +71,7 @@ declare class Deque { /** * Obtains the header element of a deque and delete the element. * @return the T type - * @throws an exception if the deque is empty + * @throws { BusinessError } 10200011 - The popFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -73,7 +79,7 @@ declare class Deque { /** * Obtains the end element of a deque and delete the element. * @return the T type - * @throws an exception if the deque is empty + * @throws { BusinessError } 10200011 - The popLast method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -86,6 +92,8 @@ declare class Deque { * @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 + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -93,6 +101,7 @@ declare class Deque { thisArg?: Object): void; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.HashMap.d.ts b/api/@ohos.util.HashMap.d.ts index db6a86247baa4b3e78694a1eb9ba067168dc6964..46db82f142572f447e02c83f080403326ae4331a 100644 --- a/api/@ohos.util.HashMap.d.ts +++ b/api/@ohos.util.HashMap.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The HashMap's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -28,6 +30,7 @@ declare class HashMap { /** * Returns whether the Map object contains elements * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -36,6 +39,7 @@ declare class HashMap { * Returns whether a key is contained in this map * @param key need to determine whether to include the key * @return the boolean type + * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -44,6 +48,7 @@ declare class HashMap { * Returns whether a value is contained in this map * @param value need to determine whether to include the value * @return the boolean type + * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -52,6 +57,7 @@ declare class HashMap { * 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 + * @throws { BusinessError } 10200011 - The get method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -59,6 +65,8 @@ declare class HashMap { /** * Adds all element groups in one map to another map * @param map the Map object to add members + * @throws { BusinessError } 10200011 - The setAll method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -68,6 +76,8 @@ declare class HashMap { * @param key Added or updated targets * @param value Added or updated value * @returns the map object after set + * @throws { BusinessError } 10200011 - The set method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -76,24 +86,28 @@ declare class HashMap { * Remove a specified element from a Map object * @param key Target to be deleted * @return Target mapped value + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ remove(key: K): V; /** * Clear all element groups in the map + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ clear(): void; /** * Returns a new Iterator object that contains the keys contained in this map + * @throws { BusinessError } 10200011 - The keys method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ keys(): IterableIterator; /** * Returns a new Iterator object that contains the values contained in this map + * @throws { BusinessError } 10200011 - The values method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -103,6 +117,7 @@ declare class HashMap { * @param key Updated targets * @param newValue Updated the target mapped value * @returns the boolean type(Is there a target pointed to by the key) + * @throws { BusinessError } 10200011 - The replace method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -110,6 +125,8 @@ declare class HashMap { /** * Executes the given callback function once for each real key in the map. * It does not perform functions on deleted keys + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -117,12 +134,14 @@ declare class HashMap { thisArg?: Object): void; /** * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ entries(): IterableIterator<[K, V]>; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.HashSet.d.ts b/api/@ohos.util.HashSet.d.ts index 88c292927a8e856c7d133e020cc42fe3ed8a9204..e10b40ea0b47fd04996a2174a6d24ead3d4772fa 100644 --- a/api/@ohos.util.HashSet.d.ts +++ b/api/@ohos.util.HashSet.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -28,6 +30,7 @@ declare class HashSet { /** * Returns whether the Set object contains elements * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -36,6 +39,8 @@ declare class HashSet { * Returns whether the Set object contain s the elements * @param value need to determine whether to include the element * @return the boolean type + * @throws { BusinessError } 10200011 - The has method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -44,6 +49,8 @@ declare class HashSet { * 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) + * @throws { BusinessError } 10200011 - The add method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -52,18 +59,23 @@ declare class HashSet { * Remove a specified element from a Set object * @param value Target to be deleted * @return the boolean type(Is there contain this element) + * @throws { BusinessError } 10200011 - The remove method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ - remove(value: T): boolean; + remove(value: T): boolean; /** * Clears all element groups in a set + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ clear(): void; /** * Executes a provided function once for each value in the Set object. + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -71,18 +83,21 @@ declare class HashSet { thisArg?: Object): void; /** * Returns a new Iterator object that contains the values contained in this set + * @throws { BusinessError } 10200011 - The values method cannot be bound. * @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 + * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ entries(): IterableIterator<[T, T]>; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.LightWeightMap.d.ts b/api/@ohos.util.LightWeightMap.d.ts index cc34b5dfbf3ce63e4f09c309eef727a14da94b55..94862c4fc19a292f183365c87a188e24a8a507d2 100644 --- a/api/@ohos.util.LightWeightMap.d.ts +++ b/api/@ohos.util.LightWeightMap.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The LightWeightMap's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -29,6 +31,8 @@ declare class LightWeightMap { * Returns whether this map has all the object in a specified map * @param map the Map object to compare * @return the boolean type + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200011 - The hasAll method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -37,6 +41,7 @@ declare class LightWeightMap { * Returns whether a key is contained in this map * @param key need to determine whether to include the key * @return the boolean type + * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -45,6 +50,7 @@ declare class LightWeightMap { * Returns whether a value is contained in this map * @param value need to determine whether to include the value * @return the boolean type + * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -53,12 +59,15 @@ declare class LightWeightMap { * 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 + * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @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 + * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -67,6 +76,7 @@ declare class LightWeightMap { * 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 + * @throws { BusinessError } 10200011 - The get method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -75,6 +85,7 @@ declare class LightWeightMap { * 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 + * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -83,6 +94,7 @@ declare class LightWeightMap { * 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 + * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -90,6 +102,7 @@ declare class LightWeightMap { /** * Returns whether the Map object contains elements * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -98,12 +111,16 @@ declare class LightWeightMap { * 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 + * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ getKeyAt(index: number): K; /** * Obtains a ES6 iterator that contains all the keys of an LightWeightMap container + * @throws { BusinessError } 10200011 - The keys method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -111,6 +128,8 @@ declare class LightWeightMap { /** * Adds all element groups in one map to another map * @param map the Map object to add members + * @throws { BusinessError } 10200011 - The setAll method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -120,6 +139,7 @@ declare class LightWeightMap { * @param key Added or updated targets * @param value Added or updated value * @returns the map object after set + * @throws { BusinessError } 10200011 - The set method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -128,6 +148,7 @@ declare class LightWeightMap { * Remove the mapping for this key from this map if present * @param key Target to be deleted * @return Target mapped value + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -136,6 +157,8 @@ declare class LightWeightMap { * 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) + * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -143,6 +166,7 @@ declare class LightWeightMap { /** * Removes all of the mapping from this map * The map will be empty after this call returns + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -152,6 +176,9 @@ declare class LightWeightMap { * @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) + * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -159,6 +186,8 @@ declare class LightWeightMap { /** * Executes the given callback function once for each real key in the map. * It does not perform functions on deleted keys + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -166,12 +195,14 @@ declare class LightWeightMap { thisArg?: Object): void; /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @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 + * @throws { BusinessError } 10200011 - The toString method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -180,12 +211,16 @@ declare class LightWeightMap { * Obtains the value identified by index in an LightWeightMap container * @param index Target subscript for search * @return the value of key-value pairs + * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ getValueAt(index: number): V; /** * Returns an iterator of the values contained in this map + * @throws { BusinessError } 10200011 - The values method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.LightWeightSet.d.ts b/api/@ohos.util.LightWeightSet.d.ts index e882104ee87cb7c09e99f1c70d8670d9ba7cac29..628504e6144dfd40d1302c2b565c1dcf150d1f6b 100644 --- a/api/@ohos.util.LightWeightSet.d.ts +++ b/api/@ohos.util.LightWeightSet.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The LightWeightSet's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -29,6 +31,7 @@ declare class LightWeightSet { * 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) + * @throws { BusinessError } 10200011 - The add method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -37,6 +40,8 @@ declare class LightWeightSet { * 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) + * @throws { BusinessError } 10200011 - The addAll method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -45,6 +50,8 @@ declare class LightWeightSet { * Returns whether this set has all the object in a specified set * @param set the Set object to compare * @return the boolean type + * @throws { BusinessError } 10200011 - The hasAll method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -53,6 +60,7 @@ declare class LightWeightSet { * Checks whether an LightWeightSet container has a specified key * @param key need to determine whether to include the key * @return the boolean type + * @throws { BusinessError } 10200011 - The has method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -61,6 +69,7 @@ declare class LightWeightSet { * 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 + * @throws { BusinessError } 10200011 - The equal method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -69,6 +78,9 @@ declare class LightWeightSet { * 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 + * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -77,6 +89,7 @@ declare class LightWeightSet { * 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 + * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -85,6 +98,7 @@ declare class LightWeightSet { * Deletes an object of a specified Object type from an LightWeightSet container * @param key Target to be deleted * @return Target element + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -93,6 +107,8 @@ declare class LightWeightSet { * 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) + * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -100,6 +116,7 @@ declare class LightWeightSet { /** * Removes all of the mapping from this map * The map will be empty after this call returns + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -107,6 +124,8 @@ declare class LightWeightSet { /** * Executes the given callback function once for each real key in the map. * It does not perform functions on deleted keys + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -114,6 +133,7 @@ declare class LightWeightSet { thisArg?: Object): void; /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -126,6 +146,7 @@ declare class LightWeightSet { toString(): String; /** * Obtains an Array that contains all the objects of an LightWeightSet container. + * @throws { BusinessError } 10200011 - The toArray method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -134,24 +155,29 @@ declare class LightWeightSet { * 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 + * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ getValueAt(index: number): T; /** * Returns a ES6 iterator of the values contained in this Set + * @throws { BusinessError } 10200011 - The values method cannot be bound. * @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 + * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ entries(): IterableIterator<[T, T]>; /** * Returns whether the set object contains elements + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.LinkedList.d.ts b/api/@ohos.util.LinkedList.d.ts index e81ef5c4d2404ddac05c66bf8de1068439ccab00..c46491eba32382c16c172a2e3140eb4390a12326 100644 --- a/api/@ohos.util.LinkedList.d.ts +++ b/api/@ohos.util.LinkedList.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The LinkedList's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -29,6 +31,7 @@ declare class LinkedList { * 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. + * @throws { BusinessError } 10200011 - The add method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -37,7 +40,9 @@ declare class LinkedList { * 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 + * @throws { BusinessError } 10200011 - The insert method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -47,6 +52,8 @@ declare class LinkedList { * or returns undefined if this linkedlist is empty * @param index specified position * @return the T type + * @throws { BusinessError } 10200011 - The get method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -54,6 +61,7 @@ declare class LinkedList { /** * Inserts the specified element at the beginning of this LinkedList. * @param element the element to add + * @throws { BusinessError } 10200011 - The addFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -61,7 +69,8 @@ declare class LinkedList { /** * Retrieves and removes the head (first element) of this linkedlist. * @return the head of this list - * @throws NoSuchElementException if this linkedlist is empty + * @throws { BusinessError } 10200011 - The removeFirst method cannot be bound. + * @throws { BusinessError } 10200010 - Container is empty. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -69,16 +78,17 @@ declare class LinkedList { /** * Removes and returns the last element from this linkedlist. * @return the head of this list - * @throws NoSuchElementException if this linkedlist is empty + * @throws { BusinessError } 10200011 - The removeLast method cannot be bound. + * @throws { BusinessError } 10200010 - Container 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 + * @throws { BusinessError } 10200011 - The has method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -88,6 +98,7 @@ declare class LinkedList { * 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. + * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -97,6 +108,9 @@ declare class LinkedList { * @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 + * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -107,6 +121,7 @@ declare class LinkedList { * 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 + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -117,6 +132,8 @@ declare class LinkedList { * 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 + * @throws { BusinessError } 10200011 - The removeFirstFound method cannot be bound. + * @throws { BusinessError } 10200010 - Container is empty. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -127,6 +144,8 @@ declare class LinkedList { * 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 + * @throws { BusinessError } 10200011 - The removeLastFound method cannot be bound. + * @throws { BusinessError } 10200010 - Container is empty. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -136,6 +155,7 @@ declare class LinkedList { * or -1 if the linkedlist does not contain the element. * @param element element to find * @return the number type + * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -144,6 +164,7 @@ declare class LinkedList { * 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 + * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -152,6 +173,7 @@ declare class LinkedList { * 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 + * @throws { BusinessError } 10200011 - The getLast method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -161,6 +183,9 @@ declare class LinkedList { * @param element replaced element * @param index index to find * @return the T type ,returns undefined if linkedList is empty + * @throws { BusinessError } 10200011 - The set method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -174,6 +199,8 @@ declare class LinkedList { * @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 + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -182,6 +209,7 @@ declare class LinkedList { /** * Removes all of the elements from this linkedlist.The linkedlist will * be empty after this call returns.length becomes 0 + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -189,6 +217,7 @@ declare class LinkedList { /** * Returns a shallow copy of this instance. (The elements themselves are not copied.) * @return this linkedlist instance + * @throws { BusinessError } 10200011 - The clone method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -196,12 +225,14 @@ declare class LinkedList { /** * convert linkedlist to array * @return the Array type + * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ convertToArray(): Array; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.List.d.ts b/api/@ohos.util.List.d.ts index fa79586ecab781eea468a9c5ecab8cd710371a8d..e2d80d057590799521f8a838d88cf83c6d04b227 100644 --- a/api/@ohos.util.List.d.ts +++ b/api/@ohos.util.List.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The List's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -29,6 +31,7 @@ declare class List { * 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. + * @throws { BusinessError } 10200011 - The add method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -37,7 +40,9 @@ declare class List { * 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 + * @throws { BusinessError } 10200011 - The insert method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -47,6 +52,8 @@ declare class List { * or returns undefined if this list is empty * @param index specified position * @return the T type + * @throws { BusinessError } 10200011 - The get method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -55,6 +62,7 @@ declare class List { * 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 + * @throws { BusinessError } 10200011 - The has method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -64,6 +72,7 @@ declare class List { * 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. + * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -73,6 +82,9 @@ declare class List { * @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 + * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -83,6 +95,7 @@ declare class List { * 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 + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -92,6 +105,7 @@ declare class List { * or -1 if the list does not contain the element. * @param element element to find * @return the number type + * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -100,6 +114,7 @@ declare class List { * 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 + * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -108,6 +123,7 @@ declare class List { * 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 + * @throws { BusinessError } 10200011 - The getLast method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -117,6 +133,9 @@ declare class List { * @param element replaced element * @param index index to find * @return the T type + * @throws { BusinessError } 10200011 - The set method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -126,6 +145,7 @@ declare class List { * return true, otherwise return false. * @param obj Compare objects * @return the boolean type + * @throws { BusinessError } 10200011 - The equal method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -139,6 +159,8 @@ declare class List { * @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 + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -152,6 +174,8 @@ declare class List { * minus firstValue, it returns an list sorted in descending order; * @param firstValue (Optional) previous element * @param secondValue (Optional) next elements + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200011 - The sort method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -159,6 +183,7 @@ declare class List { /** * Removes all of the elements from this list.The list will * be empty after this call returns.length becomes 0 + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -167,8 +192,9 @@ declare class List { * 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 + * @throws { BusinessError } 10200011 - The getSubList method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -182,14 +208,17 @@ declare class List { * @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 + * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ replaceAllElements(callbackfn: (value: T, index?: number, list?: List) => T, - thisArg?: Object): void; + thisArg?: Object): void; /** * convert list to array * @return the Array type + * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -197,12 +226,14 @@ declare class List { /** * Determine whether list is empty and whether there is an element * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ isEmpty(): boolean; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.PlainArray.d.ts b/api/@ohos.util.PlainArray.d.ts index 37012f6ad2a22f9b0648ae87ee8e4cbbd40609f4..ef10608a24449a56279329a410c158a605afa5ed 100644 --- a/api/@ohos.util.PlainArray.d.ts +++ b/api/@ohos.util.PlainArray.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The PlainArray's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -29,19 +31,22 @@ declare class PlainArray { * 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 + * @throws { BusinessError } 10200011 - The add method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ add(key: number, value: T): void; /** * Clears the current PlainArray object + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ clear(): void; /** * Obtains a clone of the current PlainArray object + * @throws { BusinessError } 10200011 - The clone method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -50,6 +55,8 @@ declare class 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 + * @throws { BusinessError } 10200011 - The has method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -58,6 +65,8 @@ declare class PlainArray { * Queries the value associated with the specified key * @param key Looking for goals * @return the value of key-value pairs + * @throws { BusinessError } 10200011 - The get method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -66,21 +75,25 @@ declare class PlainArray { * Queries the index for a specified key * @param key Looking for goals * @return Subscript corresponding to target + * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @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 - */ + * Queries the index for a specified value + * @param value Looking for goals + * @return Subscript corresponding to target + * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound. + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ getIndexOfValue(value: T): number; /** * Checks whether the current PlainArray object is empty * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -89,6 +102,8 @@ declare class PlainArray { * Queries the key at a specified index * @param index Target subscript for search * @return the key of key-value pairs + * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -97,6 +112,8 @@ declare class PlainArray { * 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 + * @throws { BusinessError } 10200011 - The remove method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -105,6 +122,8 @@ declare class PlainArray { * 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 + * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -114,6 +133,9 @@ declare class PlainArray { * @param index remove start index * @param size Expected deletion quantity * @return Actual deleted quantity + * @throws { BusinessError } 10200011 - The removeRangeFrom method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -122,12 +144,16 @@ declare class PlainArray { * Update value on specified index * @param index Target subscript for search * @param value Updated the target mapped value + * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ setValueAt(index: number, value: T): void; /** * Obtains the string representation of the PlainArray object + * @throws { BusinessError } 10200011 - The toString method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -136,12 +162,17 @@ declare class PlainArray { * Queries the value at a specified index * @param index Target subscript for search * @return the value of key-value pairs + * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. + * @throws { BusinessError } 10200001 - The type of parameters are out of range. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ getValueAt(index: number): T; /** * Executes a provided function once for each value in the PlainArray object. + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -149,6 +180,7 @@ declare class PlainArray { thisArg?: Object): void; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.Queue.d.ts b/api/@ohos.util.Queue.d.ts index 69c2762bd43935e6c3daa47b1505bfc369257a2a..20443d8d114b69ba1050f999c90dd2d2a1ece6c6 100644 --- a/api/@ohos.util.Queue.d.ts +++ b/api/@ohos.util.Queue.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -30,6 +32,7 @@ declare class Queue { * so immediately without violating capacity restrictions. * @param element to be appended to this queue * @return the boolean type + * @throws { BusinessError } 10200011 - The add method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -37,7 +40,7 @@ declare class Queue { /** * Obtains the header element of a queue. * @return the T type - * @throws an exception if the queue is empty + * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -45,7 +48,7 @@ declare class Queue { /** * Retrieves and removes the head of this queue * @return the T type - * @throws an exception if the queue is empty + * @throws { BusinessError } 10200011 - The pop method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -59,6 +62,8 @@ declare class Queue { * @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 + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -66,6 +71,7 @@ declare class Queue { thisArg?: Object): void; /** * returns an iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.Stack.d.ts b/api/@ohos.util.Stack.d.ts index 59ef60e5d47745ca24830a0eadbadfea0a8ae659..e1c4ade374391e3360c398c92475436a1c73a5d5 100644 --- a/api/@ohos.util.Stack.d.ts +++ b/api/@ohos.util.Stack.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,9 +12,11 @@ * 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. + * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -28,6 +30,7 @@ declare class Stack { /** * Tests if this stack is empty * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -36,6 +39,7 @@ declare class Stack { * 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 + * @throws { BusinessError } 10200011 - The peek method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -44,6 +48,7 @@ declare class Stack { * 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 + * @throws { BusinessError } 10200011 - The pop method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -52,6 +57,7 @@ declare class Stack { * Pushes an item onto the top of this stack * @param item to be appended to this Stack * @returns the T type + * @throws { BusinessError } 10200011 - The push method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -60,6 +66,7 @@ declare class Stack { * 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 + * @throws { BusinessError } 10200011 - The locate method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -73,6 +80,8 @@ declare class Stack { * @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 + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -80,6 +89,7 @@ declare class Stack { thisArg?: Object): void; /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.TreeMap.d.ts b/api/@ohos.util.TreeMap.d.ts index 2b4647f18f5ec284cb51099c245152dd708c5f27..3598b077370e094707871c5b0c3807c6a3784076 100644 --- a/api/@ohos.util.TreeMap.d.ts +++ b/api/@ohos.util.TreeMap.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,12 +12,16 @@ * 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 + * @throws { BusinessError } 10200012 - The TreeMap's constructor cannot be directly invoked. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -31,6 +35,7 @@ declare class TreeMap { /** * Returns whether the Map object contains elements * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -39,6 +44,7 @@ declare class TreeMap { * Returns whether a key is contained in this map * @param key need to determine whether to include the key * @return the boolean type + * @throws { BusinessError } 10200011 - The hasKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -47,6 +53,7 @@ declare class TreeMap { * Returns whether a value is contained in this map * @param value need to determine whether to include the value * @return the boolean type + * @throws { BusinessError } 10200011 - The hasValue method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -55,6 +62,7 @@ declare class TreeMap { * 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 + * @throws { BusinessError } 10200011 - The get method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -63,6 +71,7 @@ declare class TreeMap { * Obtains the first sorted key in the treemap. * Or returns undefined if tree map is empty * @return value or undefined + * @throws { BusinessError } 10200011 - The getFirstKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -71,6 +80,7 @@ declare class TreeMap { * Obtains the last sorted key in the treemap. * Or returns undefined if tree map is empty * @return value or undefined + * @throws { BusinessError } 10200011 - The getLastKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -78,6 +88,8 @@ declare class TreeMap { /** * Adds all element groups in one map to another map * @param map the Map object to add members + * @throws { BusinessError } 10200011 - The setAll method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -87,6 +99,8 @@ declare class TreeMap { * @param key Added or updated targets * @param value Added or updated value * @returns the map object after set + * @throws { BusinessError } 10200011 - The set method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -94,6 +108,7 @@ declare class TreeMap { /** * Remove a specified element from a Map object * @param key Target to be deleted + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @return Target mapped value * @since 8 * @syscap SystemCapability.Utils.Lang @@ -101,6 +116,7 @@ declare class TreeMap { remove(key: K): V; /** * Clear all element groups in the map + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -109,6 +125,7 @@ declare class TreeMap { * 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 + * @throws { BusinessError } 10200011 - The getLowerKey method cannot be bound. * @return key or undefined * @since 8 * @syscap SystemCapability.Utils.Lang @@ -119,18 +136,21 @@ declare class TreeMap { * if the key does not exist, undefied is returned * @param key Objective of comparison * @return key or undefined + * @throws { BusinessError } 10200011 - The getHigherKey method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ getHigherKey(key: K): K; /** * Returns a new Iterator object that contains the keys contained in this map + * @throws { BusinessError } 10200011 - The keys method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ keys(): IterableIterator; /** * Returns a new Iterator object that contains the values contained in this map + * @throws { BusinessError } 10200011 - The values method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -140,6 +160,7 @@ declare class TreeMap { * @param key Updated targets * @param value Updated the target mapped value * @returns the boolean type(Is there a target pointed to by the key) + * @throws { BusinessError } 10200011 - The replace method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -147,6 +168,8 @@ declare class TreeMap { /** * Executes the given callback function once for each real key in the map. * It does not perform functions on deleted keys + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -154,12 +177,14 @@ declare class TreeMap { thisArg?: Object): void; /** * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order + * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ entries(): IterableIterator<[K, V]>; /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.TreeSet.d.ts b/api/@ohos.util.TreeSet.d.ts index a71ef36bf015f787b3d791c05ac4f84e805fbeb0..77d9e5635b2b40f251cfdea6227d00a8b392a3c5 100644 --- a/api/@ohos.util.TreeSet.d.ts +++ b/api/@ohos.util.TreeSet.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,12 +12,15 @@ * 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 + * @throws { BusinessError } 10200012 - The TreeSet's constructor cannot be directly invoked. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -31,6 +34,7 @@ declare class TreeSet { /** * Returns whether the Set object contains elements * @return the boolean type + * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -39,6 +43,7 @@ declare class TreeSet { * Returns whether the Set object contain s the elements * @param value need to determine whether to include the element * @return the boolean type + * @throws { BusinessError } 10200011 - The has method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -47,6 +52,8 @@ declare class TreeSet { * 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) + * @throws { BusinessError } 401 - The type of parameters are invalid. + * @throws { BusinessError } 10200011 - The add method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -55,12 +62,14 @@ declare class TreeSet { * Remove a specified element from a Set object * @param value Target to be deleted * @return the boolean type(Is there contain this element) + * @throws { BusinessError } 10200011 - The remove method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ remove(value: T): boolean; /** * Clears all element groups in a set + * @throws { BusinessError } 10200011 - The clear method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -68,6 +77,7 @@ declare class TreeSet { /** * Gets the first elements in a set * @return value or undefined + * @throws { BusinessError } 10200011 - The getFirstValue method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -75,6 +85,7 @@ declare class TreeSet { /** * Gets the last elements in a set * @return value or undefined + * @throws { BusinessError } 10200011 - The getLastValue method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -84,6 +95,8 @@ declare class TreeSet { * if the key does not exist, undefied is returned * @param key Objective of comparison * @return key or undefined + * @throws { BusinessError } 10200011 - The getLowerValue method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -93,6 +106,8 @@ declare class TreeSet { * if the key does not exist, undefied is returned * @param key Objective of comparison * @return key or undefined + * @throws { BusinessError } 10200011 - The getHigherValue method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -100,6 +115,7 @@ declare class TreeSet { /** * Return and delete the first element, returns undefined if tree set is empty * @return first value or undefined + * @throws { BusinessError } 10200011 - The popFirst method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -107,12 +123,15 @@ declare class TreeSet { /** * Return and delete the last element, returns undefined if tree set is empty * @return last value or undefined + * @throws { BusinessError } 10200011 - The popLast method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ popLast(): T; /** * Executes a provided function once for each value in the Set object. + * @throws { BusinessError } 10200011 - The forEach method cannot be bound. + * @throws { BusinessError } 401 - The type of parameters are invalid. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -120,18 +139,21 @@ declare class TreeSet { thisArg?: Object): void; /** * Returns a new Iterator object that contains the values contained in this set + * @throws { BusinessError } 10200011 - The values method cannot be bound. * @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 + * @throws { BusinessError } 10200011 - The entries method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ entries(): IterableIterator<[T, T]>; /** * returns an ES6 iterator.Each item of the iterator is a Javascript Object + * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. * @since 8 * @syscap SystemCapability.Utils.Lang */ diff --git a/api/@ohos.util.Vector.d.ts b/api/@ohos.util.Vector.d.ts index 67d310c7b500224b7144697ce465ce1991beac8e..8b1603b83a85af4d408c6388d209e82e845a6be4 100644 --- a/api/@ohos.util.Vector.d.ts +++ b/api/@ohos.util.Vector.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -12,6 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * @syscap SystemCapability.Utils.Lang + * @since 8 + * @deprecated since 9 + */ declare class Vector { /** * A constructor used to create a Vector object. diff --git a/api/@ohos.util.d.ts b/api/@ohos.util.d.ts index f4202b0e73352c42ff8330cadbd634598f2f4e65..71a15492b2603cdb5f9f2c4c63958bc901bdb122 100644 --- a/api/@ohos.util.d.ts +++ b/api/@ohos.util.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -39,28 +39,69 @@ declare namespace util { * %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 + * @deprecated since 9 + * @useinstead ohos.util.format * @syscap SystemCapability.Utils.Lang - * @param format styled string - * @param args data to be formatted + * @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; + /** + * %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 9 + * @syscap SystemCapability.Utils.Lang + * @param format Styled string + * @param args Data to be formatted + * @return Return the character string formatted in a specific format + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + function format(format: string, ...args: Object[]): string; + /** * Get the string name of the system errno. * @since 7 + * @deprecated since 9 + * @useinstead ohos.util.errnoToString * @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 + * @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; + /** + * Get the string name of the system errno. + * @since 9 + * @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 + * @throws {BusinessError} 401 - The type of errno must be number. + */ + function errnoToString(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 + * @param original Asynchronous function + * @throws {BusinessError} 401 - The type of original must be Function. */ function callbackWrapper(original: Function): (err: Object, value: Object) => void; @@ -69,52 +110,63 @@ declare namespace util { * 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 + * @param original Asynchronous function + * @return Return a function that returns promises + * @throws {BusinessError} 401 - The type of original must be Function. */ - function promisify(original: (err: Object, value: Object) => void): Function; + 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 + * @useinstead ohos.util.promisify * @syscap SystemCapability.Utils.Lang - * @param original asynchronous function - * @return return a version that returns promises + * @param original Asynchronous function + * @return Return a version that returns promises */ function promiseWrapper(original: (err: Object, value: Object) => void): Object; - + /** - * Generate a random RFC 4122 version 4 UUID using a cryptographically secure random number generator. - * @since 9 - * @syscap SystemCapability.Utils.Lang - * @param entropyCache whether to generate the UUID with using the cache. Default: true. - * @return return a string representing this UUID. - */ + * Generate a random RFC 4122 version 4 UUID using a cryptographically secure random number generator. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param entropyCache Whether to generate the UUID with using the cache. Default: true. + * @return Return a string representing this UUID. + * @throws {BusinessError} 401 - The type of entropyCache must be boolean. + */ function randomUUID(entropyCache?: boolean): string; /** - * Generate a random RFC 4122 version 4 UUID using a cryptographically secure random number generator. - * @since 9 - * @syscap SystemCapability.Utils.Lang - * @param entropyCache whether to generate the UUID with using the cache. Default: true. - * @return return a Uint8Array representing this UUID. - */ + * Generate a random RFC 4122 version 4 UUID using a cryptographically secure random number generator. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param entropyCache Whether to generate the UUID with using the cache. Default: true. + * @return Return a Uint8Array representing this UUID. + * @throws {BusinessError} 401 - The type of entropyCache must be boolean. + */ function randomBinaryUUID(entropyCache?: boolean): Uint8Array; /** - * Parse a UUID from the string standard representation as described in the RFC 4122 version 4. - * @since 9 - * @syscap SystemCapability.Utils.Lang - * @param uuid string that specifies a UUID - * @return return a Uint8Array representing this UUID. Throw SyntaxError if parsing fails. - */ + * Parse a UUID from the string standard representation as described in the RFC 4122 version 4. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param uuid String that specifies a UUID + * @return Return a Uint8Array representing this UUID. Throw SyntaxError if parsing fails. + * @throws {BusinessError} 401 - The type of uuid must be string. + */ function parseUUID(uuid: string): Uint8Array; + /** + * The TextEncoder represents a text encoder that accepts a string as input, + * encodes it in UTF-8 format, and outputs UTF-8 byte stream. + * @syscap SystemCapability.Utils.Lang + * @since 7 + */ class TextDecoder { /** - * the source encoding's name, lowercased. + * The source encoding's name, lowercased. * @since 7 * @syscap SystemCapability.Utils.Lang */ @@ -135,22 +187,45 @@ declare namespace util { readonly ignoreBOM = false; /** - * the textEncoder constructor. - * @param 7 + * The textEncoder constructor. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.util.constructor * @syscap SystemCapability.Utils.Lang - * @param encoding decoding format + * @param encoding Decoding format */ constructor( encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean }, ); + /** + * The textEncoder constructor. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + + /** + * Check the validity of parameters. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param encoding Decoding format + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + static create( + encoding?: string, + options?: { fatal?: boolean; ignoreBOM?: boolean }, + ): TextDecoder; + /** * Returns the result of running encoding's decoder. * @since 7 + * @deprecated since 9 + * @useinstead ohos.util.decodeWithStream * @syscap SystemCapability.Utils.Lang - * @param input decoded numbers in accordance with the format - * @return return decoded text + * @param input Decoded numbers in accordance with the format + * @return Return decoded text */ decode(input: Uint8Array, options?: { stream?: false }): string; @@ -158,12 +233,19 @@ declare namespace util { * Returns the result of running encoding's decoder. * @since 9 * @syscap SystemCapability.Utils.Lang - * @param input decoded numbers in accordance with the format - * @return return decoded text + * @param input Decoded numbers in accordance with the format + * @return Return decoded text + * @throws {BusinessError} 401 - if the input parameters are invalid. */ - decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string; + decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string; } + /** + * The TextDecoder interface represents a text decoder. + * The decoder takes the byte stream as the input and outputs the String string. + * @syscap SystemCapability.Utils.Lang + * @since 7 + */ class TextEncoder { /** * Encoding format. @@ -173,36 +255,51 @@ declare namespace util { readonly encoding = "utf-8"; /** - * the textEncoder constructor. + * The textEncoder constructor. * @since 7 * @syscap SystemCapability.Utils.Lang */ constructor(); /** - * the textEncoder constructor. + * The textEncoder constructor. * @since 9 * @syscap SystemCapability.Utils.Lang * @param encoding The string for encoding format. + * @throws {BusinessError} 401 - The type of encoding must be string. */ constructor(encoding?: string); /** * Returns the result of encoder. * @since 7 + * @deprecated since 9 + * @useinstead ohos.util.encodeInto * @syscap SystemCapability.Utils.Lang - * @param The string to be encoded. - * @return returns the encoded text. + * @param input The string to be encoded. + * @return Returns the encoded text. */ encode(input?: string): Uint8Array; /** - * encode string, write the result to dest array. + * Returns the result of encoder. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param input The string to be encoded. + * @return Returns the encoded text. + * @throws {BusinessError} 401 - The type of input must be string. + */ + encodeInto(input?: string): Uint8Array; + + /** + * Encode string, write the result to dest array. * @since 7 + * @deprecated since 9 + * @useinstead ohos.util.encodeIntoUint8Array * @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 + * @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. */ @@ -210,41 +307,98 @@ declare namespace util { input: string, dest: Uint8Array, ): { read: number; written: number }; - } + /** + * Encode string, write the result to dest array. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + encodeIntoUint8Array( + input: string, + dest: Uint8Array, + ): { read: number; written: number }; + } + + /** + * The rational number is mainly to compare rational numbers and obtain the numerator and denominator. + * @syscap SystemCapability.Utils.Lang + * @since 8 + */ class RationalNumber { /** * A constructor used to create a RationalNumber instance with a given numerator and denominator. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.constructor * @syscap SystemCapability.Utils.Lang * @param numerator An integer number * @param denominator An integer number */ constructor(numerator: number, denominator: number); + + /** + * A constructor used to create a RationalNumber instance with a given numerator and denominator. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + constructor(); + + /** + * Check the validity of parameters. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param numerator An integer number + * @param denominator An integer number + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + static parseRationalNumber(numerator: number, denominator: number): RationalNumber; + /** * Creates a RationalNumber object based on a given string. * @since 8 * @syscap SystemCapability.Utils.Lang - * @param String Expression of Rational Numbers + * @param rationalString String Expression of Rational Numbers * @return Returns a RationalNumber object generated based on the given string. + * @throws {BusinessError} 401 - The type of rationalString must be string. */ static createRationalFromString(rationalString: string): RationalNumber​; + /** * Compares the current RationalNumber object to the given object. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.compare * @syscap SystemCapability.Utils.Lang - * @param An object of other rational numbers + * @param another An object of other rational numbers * @return Returns 0 or 1, or -1, depending on the comparison. */ compareTo(another :RationalNumber): number; + + /** + * Compares the current RationalNumber object to the given object. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param another An object of other rational numbers + * @return Returns 0 or 1, or -1, depending on the comparison. + * @throws {BusinessError} 401 - The type of another must be RationalNumber. + */ + compare(another :RationalNumber): number; + /** * Compares two objects for equality. * @since 8 * @syscap SystemCapability.Utils.Lang - * @param An object + * @param obj 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 @@ -252,15 +406,30 @@ declare namespace util { * @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 + * @deprecated since 9 + * @useinstead ohos.util.getCommonFactor * @syscap SystemCapability.Utils.Lang - * @param number1 is an integer. - * @param number2 is an integer. + * @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; + + /** + * Get the greatest common divisor of two integers. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + static getCommonFactor(number1: number, number2: number): number; + /** * Gets the denominator of the current object. * @since 8 @@ -268,6 +437,7 @@ declare namespace util { * @return Returns the denominator of the current object. */ getDenominator(): number; + /** * Gets the numerator​ of the current object. * @since 8 @@ -275,13 +445,15 @@ declare namespace util { * @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; + isFinite(): boolean; + /** * Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. * @since 8 @@ -289,6 +461,7 @@ declare namespace util { * @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 @@ -296,6 +469,7 @@ declare namespace util { * @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 @@ -305,132 +479,192 @@ declare namespace util { toString(): string; } + /** + * The LruBuffer algorithm replaces the least used data with new data when the buffer space is insufficient. + * @syscap SystemCapability.Utils.Lang + * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache + */ class LruBuffer { /** * Default constructor used to create a new LruBuffer instance with the default capacity of 64. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.constructor * @syscap SystemCapability.Utils.Lang * @param capacity Indicates the capacity to customize for the buffer. */ - constructor(capacity?:number); + constructor(capacity?: number); + /** * Updates the buffer capacity to a specified capacity. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.updateCapacity * @syscap SystemCapability.Utils.Lang * @param newCapacity Indicates the new capacity to set. */ updateCapacity(newCapacity: number):void + /** - *Returns a string representation of the object. + * Returns a string representation of the object. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.toString * @syscap SystemCapability.Utils.Lang * @return Returns the string representation of the object and outputs the string representation of the object. */ - toString():string + toString(): string + /** * Obtains a list of all values in the current buffer. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.length * @syscap SystemCapability.Utils.Lang * @return Returns the total number of values in the current buffer. */ - length:number + length: number + /** * Obtains the capacity of the current buffer. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.getCapacity * @syscap SystemCapability.Utils.Lang * @return Returns the capacity of the current buffer. */ getCapacity(): number; + /** * Clears key-value pairs from the current buffer. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.clear * @syscap SystemCapability.Utils.Lang */ clear(): void; + /** * Obtains the number of times createDefault(Object) returned a value. * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.getCreateCount * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.getMissCount * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.getRemovalCount * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.getMatchCount * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.getPutCount * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.isEmpty * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.get * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.put * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.values * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.keys * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.remove * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.afterRemoval * @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. @@ -438,144 +672,398 @@ declare namespace util { * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.contains * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.createDefault * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.entries * @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 + * @deprecated since 9 + * @useinstead ohos.util.LRUCache.[Symbol.iterator] * @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 + * The LRUCache algorithm replaces the least used data with new data when the buffer space is insufficient. * @syscap SystemCapability.Utils.Lang + * @since 9 */ - type ScopeType = ScopeComparable | number; - - class Scope{ + class LRUCache { /** - * A constructor used to create a Scope instance with the lower and upper bounds specified. - * @since 8 + * Default constructor used to create a new LruBuffer instance with the default capacity of 64. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @param lowerObj A ScopeType value - * @param upperObj A ScopeType value + * @param capacity Indicates the capacity to customize for the buffer. */ - constructor(lowerObj: ScopeType, upperObj: ScopeType); + constructor(capacity?: number); + /** - * Obtains a string representation of the current range. - * @since 8 + * Updates the buffer capacity to a specified capacity. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @return Returns a string representation of the current range object. + * @param newCapacity Indicates the new capacity to set. + * @throws {BusinessError} 401 - The type of newCapacity must be number. */ - toString(): string; + updateCapacity(newCapacity: number):void + /** - * Returns the intersection of a given range and the current range. - * @since 8 + * Returns a string representation of the object. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @param range A Scope range object - * @return Returns the intersection of a given range and the current range. + * @return Returns the string representation of the object and outputs the string representation of the object. */ - intersect(range: Scope): Scope; + toString(): string + /** - * Returns the intersection of the current range and the range specified by the given lower and upper bounds. - * @since 8 + * Obtains a list of all values in the current buffer. + * @since 9 * @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. + * @return Returns the total number of values in the current buffer. */ - intersect(lowerObj: ScopeType, upperObj: ScopeType): Scope; + length: number + /** - * Obtains the upper bound of the current range. - * @since 8 + * Obtains the capacity of the current buffer. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @return Returns the upper bound of the current range. + * @return Returns the capacity of the current buffer. */ - getUpper(): ScopeType; + getCapacity(): number; + /** - * Obtains the lower bound of the current range. - * @since 8 + * Clears key-value pairs from the current buffer. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @return Returns the lower bound of the current range. */ - getLower(): ScopeType; + clear(): void; + /** - * Creates the smallest range that includes the current range and the given lower and upper bounds. - * @since 8 + * Obtains the number of times createDefault(Object) returned a value. + * @since 9 * @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. + * @return Returns the number of times createDefault(java.lang.Object) returned a value. */ - expand(lowerObj: ScopeType, upperObj: ScopeType): Scope; + getCreateCount(): number; + /** - * Creates the smallest range that includes the current range and a given range. - * @since 8 + * Obtains the number of times that the queried values are not matched. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @param range A Scope range object - * @return Returns the smallest range that includes the current range and a given range. + * @return Returns the number of times that the queried values are not matched. */ - expand(range: Scope): Scope; + getMissCount(): number; + /** - * Creates the smallest range that includes the current range and a given value. - * @since 8 + * Obtains the number of times that values are evicted from the buffer. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @param value A ScopeType value - * @return Returns the smallest range that includes the current range and a given value. + * @return Returns the number of times that values are evicted from the buffer. */ - expand(value: ScopeType): Scope; + getRemovalCount(): number; + /** - * Checks whether a given value is within the current range. - * @since 8 + * Obtains the number of times that the queried values are successfully matched. + * @since 9 * @syscap SystemCapability.Utils.Lang - * @param range A ScopeType range - * @return If the value is within the current range return true,otherwise return false. + * @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 9 + * @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 9 + * @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 9 + * @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. + * @throws {BusinessError} 401 - The type of key must be object. + */ + get(key: K): V | undefined; + + /** + * Adds a key-value pair to the buffer. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + put(key: K, value: V): V; + + /** + * Obtains a list of all values in the current buffer. + * @since 9 + * @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 9 + * @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 9 + * @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. + * @throws {BusinessError} 401 - The type of key must be object. + */ + remove(key: K): V | undefined; + + /** + * Executes subsequent operations after a value is deleted. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + afterRemoval(isEvict: boolean, key: K, value: V, newValue: V): void; + + /** + * Checks whether the current buffer contains a specified key. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the key to check. + * @return Returns true if the buffer contains the specified key. + * @throws {BusinessError} 401 - The type of key must be object. + */ + contains(key: object): boolean; + + /** + * Executes subsequent operations if miss to compute a value for the specific key. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param key Indicates the missed key. + * @return Returns the value associated with the key. + * @throws {BusinessError} 401 - The type of key must be object. + */ + createDefault(key: K): V; + + /** + * Returns an array of key-value pairs of enumeratable properties of a given object. + * @since 9 + * @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 9 + * @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; + + /** + * The Scope interface is used to describe the valid range of a field. + * @syscap SystemCapability.Utils.Lang + * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper + */ + class Scope { + /** + * A constructor used to create a Scope instance with the lower and upper bounds specified. + * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.constructor + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.toString + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.intersect + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.intersect + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.getUpper + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.getLower + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.expand + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.expand + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.expand + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.contains + * @syscap SystemCapability.Utils.Lang + * @param value A ScopeType value + * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.contains * @syscap SystemCapability.Utils.Lang - * @param value A Scope value + * @param range A Scope range * @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 + * @deprecated since 9 + * @useinstead ohos.util.ScopeHelper.clamp * @syscap SystemCapability.Utils.Lang * @param value A ScopeType value * @return Returns a ScopeType object that a given value is clamped to the current range.. @@ -583,65 +1071,299 @@ declare namespace util { clamp(value: ScopeType): ScopeType; } - class Base64{ + /** + * The ScopeHelper interface is used to describe the valid range of a field. + * @syscap SystemCapability.Utils.Lang + * @since 9 + */ + class ScopeHelper { + /** + * A constructor used to create a Scope instance with the lower and upper bounds specified. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param lowerObj A ScopeType value + * @param upperObj A ScopeType value + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + constructor(lowerObj: ScopeType, upperObj: ScopeType); + + /** + * Obtains a string representation of the current range. + * @since 9 + * @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 9 + * @syscap SystemCapability.Utils.Lang + * @param range A Scope range object + * @return Returns the intersection of a given range and the current range. + * @throws {BusinessError} 401 - The type of range must be ScopeHelper. + */ + intersect(range: ScopeHelper): ScopeHelper; + + /** + * Returns the intersection of the current range and the range specified by the given lower and upper bounds. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + intersect(lowerObj: ScopeType, upperObj: ScopeType): ScopeHelper; + + /** + * Obtains the upper bound of the current range. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @return Returns the upper bound of the current range. + */ + getUpper(): ScopeType; + + /** + * Obtains the lower bound of the current range. + * @since 9 + * @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 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ + expand(lowerObj: ScopeType, upperObj: ScopeType): ScopeHelper; + + /** + * Creates the smallest range that includes the current range and a given range. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param range A Scope range object + * @return Returns the smallest range that includes the current range and a given range. + * @throws {BusinessError} 401 - The type of range must be ScopeHelper. + */ + expand(range: ScopeHelper): ScopeHelper; + + /** + * Creates the smallest range that includes the current range and a given value. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param value A ScopeType value + * @return Returns the smallest range that includes the current range and a given value. + * @throws {BusinessError} 401 - The type of value must be object. + */ + expand(value: ScopeType): ScopeHelper; + + /** + * Checks whether a given value is within the current range. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param value A ScopeType value + * @return If the value is within the current range return true,otherwise return false. + * @throws {BusinessError} 401 - The type of value must be object. + */ + contains(value: ScopeType): boolean; + + /** + * Checks whether a given range is within the current range. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param range A Scope range + * @return If the current range is within the given range return true,otherwise return false. + * @throws {BusinessError} 401 - The type of range must be ScopeHelper. + */ + contains(range: ScopeHelper): boolean; + + /** + * Clamps a given value to the current range. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param value A ScopeType value + * @return Returns a ScopeType object that a given value is clamped to the current range. + * @throws {BusinessError} 401 - The type of value must be object. + */ + clamp(value: ScopeType): ScopeType; + } + + /** + * Decodes a Base64 encoded String or input u8 array into a newly-allocated + * u8 array using the Base64 encoding scheme. + * @syscap SystemCapability.Utils.Lang + * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper + */ + class Base64 { /** * Constructor for creating base64 encoding and decoding * @since 8 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.constructor * @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 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.encodeSync * @syscap SystemCapability.Utils.Lang - * @param value A Uint8Array value + * @param src 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 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.encodeToStringSync * @syscap SystemCapability.Utils.Lang - * @param value A Uint8Array value + * @param src 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 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.decodeSync * @syscap SystemCapability.Utils.Lang - * @param value A Uint8Array value or value A string value + * @param src 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 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.encode * @syscap SystemCapability.Utils.Lang - * @param value A Uint8Array value + * @param src 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 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.encodeToString * @syscap SystemCapability.Utils.Lang - * @param value A Uint8Array value + * @param src A Uint8Array value * @return Returns the encoded asynchronous string. */ - encodeToString(src: Uint8Array): Promise; + 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 + * @deprecated since 9 + * @useinstead ohos.util.Base64Helper.decode * @syscap SystemCapability.Utils.Lang - * @param value A Uint8Array value or value A string value + * @param src A Uint8Array value or value A string value * @return Return the decoded asynchronous Uint8Array. */ decode(src: Uint8Array | string): Promise; } + /** + * Decodes a Base64 encoded String or input u8 array into a newly-allocated + * u8 array using the Base64 encoding scheme. + * @syscap SystemCapability.Utils.Lang + * @since 9 + */ + class Base64Helper { + /** + * Constructor for creating base64 encoding and decoding + * @since 9 + * @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 9 + * @syscap SystemCapability.Utils.Lang + * @param src A Uint8Array value + * @return Return the encoded new Uint8Array. + * @throws {BusinessError} 401 - The type of src must be Uint8Array. + */ + encodeSync(src: Uint8Array): Uint8Array; + + /** + * Encodes the specified byte array into a String using the Base64 encoding scheme. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param src A Uint8Array value + * @return Return the encoded string. + * @throws {BusinessError} 401 - The type of src must be Uint8Array. + */ + 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 9 + * @syscap SystemCapability.Utils.Lang + * @param src A Uint8Array value or value A string value + * @return Return the decoded Uint8Array. + * @throws {BusinessError} 401 - The type of src must be Uint8Array or string. + */ + 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 9 + * @syscap SystemCapability.Utils.Lang + * @param src A Uint8Array value + * @return Return the encodes asynchronous new Uint8Array. + * @throws {BusinessError} 401 - The type of src must be Uint8Array. + */ + encode(src: Uint8Array): Promise; + + /** + * Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @since 9 + * @syscap SystemCapability.Utils.Lang + * @param src A Uint8Array value + * @return Returns the encoded asynchronous string. + * @throws {BusinessError} 401 - The type of src must be Uint8Array. + */ + 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 9 + * @syscap SystemCapability.Utils.Lang + * @param src A Uint8Array value or value A string value + * @return Return the decoded asynchronous Uint8Array. + * @throws {BusinessError} 401 - The type of src must be Uint8Array or string. + */ + decode(src: Uint8Array | string): Promise; + } + + /** + * Check the type of parameter. + * @syscap SystemCapability.Utils.Lang + * @since 8 + */ class types{ /** * The types constructor diff --git a/api/@ohos.wantAgent.d.ts b/api/@ohos.wantAgent.d.ts index 48a996a4816d4cb917332e965b0ca0d4c0b1f803..9863e89de47d141f7d29f357844a65d5061cc505 100644 --- a/api/@ohos.wantAgent.d.ts +++ b/api/@ohos.wantAgent.d.ts @@ -27,6 +27,8 @@ import { TriggerInfo as _TriggerInfo } from './wantAgent/triggerInfo'; * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import wantAgent from '@ohos.wantAgent'; * @permission N/A + * @deprecated since 9 + * @useinstead ohos.app.ability.wantAgent */ declare namespace wantAgent { /** diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index 1ef2d8ad7c51ed0f0f31da3b80c89a55affcce0b..17ef1e37692a3438ae458ecb3aab9cb4a4563fff 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -19,105 +19,105 @@ import {AsyncCallback} from "./basic"; import {Resource} from 'GlobalResource'; /** - * Defines the Web's request/response header. + * This module provides the capability to manage web modules. + * * @since 9 + * @syscap SystemCapability.Web.Webview.Core */ - declare interface HeaderV9 { - /** - * Gets the key of the request/response header. - * @since 9 - */ - headerKey: string; - +declare namespace webview { /** - * Gets the value of the request/response header. + * Defines the Web's request/response header. * @since 9 */ - headerValue: string; - } + interface HeaderV9 { + /** + * Gets the key of the request/response header. + * @since 9 + */ + headerKey: string; -/** - * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. - * @since 9 - */ - declare enum HitTestTypeV9 { - /** - * The edit text. - * @since 9 - */ - EditText, + /** + * Gets the value of the request/response header. + * @since 9 + */ + headerValue: string; + } /** - * The email address. + * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. * @since 9 */ - Email, + enum HitTestTypeV9 { + /** + * The edit text. + * @since 9 + */ + EditText, - /** - * The HTML::a tag with src=http. - * @since 9 - */ - HttpAnchor, + /** + * The email address. + * @since 9 + */ + Email, - /** - * The HTML::a tag with src=http + HTML::img. - * @since 9 - */ - HttpAnchorImg, + /** + * The HTML::a tag with src=http. + * @since 9 + */ + HttpAnchor, - /** - * The HTML::img tag. - * @since 9 - */ - Img, + /** + * The HTML::a tag with src=http + HTML::img. + * @since 9 + */ + HttpAnchorImg, - /** - * The map address. - * @since 9 - */ - Map, + /** + * The HTML::img tag. + * @since 9 + */ + Img, - /** - * The phone number. - * @since 9 - */ - Phone, + /** + * The map address. + * @since 9 + */ + Map, - /** - * Other unknown HitTest. - * @since 9 - */ - Unknown, - } + /** + * The phone number. + * @since 9 + */ + Phone, -/** - * Defines the hit test value, related to {@link getHitTestValue} method. - * @since 9 - */ -declare interface HitTestValue { + /** + * Other unknown HitTest. + * @since 9 + */ + Unknown, + } /** - * Get the hit test type. - * + * Defines the hit test value, related to {@link getHitTestValue} method. * @since 9 */ - type: HitTestTypeV9; + interface HitTestValue { - /** - * Get the hit test extra data. - * - * @since 9 - */ - extra: string; -} + /** + * Get the hit test type. + * + * @since 9 + */ + type: HitTestTypeV9; + + /** + * Get the hit test extra data. + * + * @since 9 + */ + extra: string; + } -/** - * This module provides the capability to manage web modules. - * - * @since 9 - * @syscap SystemCapability.Web.Webview.Core - */ -declare namespace webview { /** * Provides basic information of web storage. * @name WebStorageOrigin @@ -371,28 +371,17 @@ declare namespace webview { */ static setCookie(url: string, value: string): void; - /** - * Save the cookies Synchronously. - * - * @since 9 - */ - static saveCookieSync(): void; - /** * Save the cookies Asynchronously. * - * @param { AsyncCallback } callback - Called after the cookies have been saved. - * The parameter will either be true if the cookies - * have been successfully saved, or false if failed. + * @param { AsyncCallback } callback - Called after the cookies have been saved. * @throws { BusinessError } 401 - Invaild input parameter. - * @return { Promise } A promise resolved after the cookies have been saved. - * The parameter will either be true if the cookies have - * been successfully saved, or false if failed. + * @return { Promise } A promise resolved after the cookies have been saved. * * @since 9 */ - static saveCookieAsync(): Promise; - static saveCookieAsync(callback: AsyncCallback): void; + static saveCookieAsync(): Promise; + static saveCookieAsync(callback: AsyncCallback): void; /** * Get whether the instance can send and accept cookies. @@ -425,7 +414,7 @@ declare namespace webview { /** * Set whether the instance should send and accept thirdparty cookies. - * By default this is set to be true. + * By default this is set to be false. * * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. * @throws { BusinessError } 401 - Invaild input parameter. @@ -536,7 +525,6 @@ declare namespace webview { * * @throws { BusinessError } 17100001 - Init error. * The WebviewController must be associted with a Web component. - * @throws { BusinessError } 17100007 - Invalid back or forward operation. * * @since 9 */ @@ -547,7 +535,6 @@ declare namespace webview { * * @throws { BusinessError } 17100001 - Init error. * The WebviewController must be associted with a Web component. - * @throws { BusinessError } 17100007 - Invalid back or forward operation. * * @since 9 */ @@ -667,7 +654,6 @@ declare namespace webview { * @throws { BusinessError } 17100001 - Init error. * The WebviewController must be associted with a Web component. * @throws { BusinessError } 17100004 - Function not enable. - * @throws { BusinessError } 17100009 - Cannot zoom in or zoom out. * * @since 9 */ @@ -679,7 +665,6 @@ declare namespace webview { * @throws { BusinessError } 17100001 - Init error. * The WebviewController must be associted with a Web component. * @throws { BusinessError } 17100004 - Function not enable. - * @throws { BusinessError } 17100009 - Cannot zoom in or zoom out. * * @since 9 */ @@ -691,7 +676,6 @@ declare namespace webview { * @throws { BusinessError } 17100001 - Init error. * The WebviewController must be associted with a Web component. * @throws { BusinessError } 17100004 - Function not enable. - * @throws { BusinessError } 17100009 - Cannot zoom in or zoom out. * * @since 9 */ @@ -759,7 +743,6 @@ declare namespace webview { * @throws { BusinessError } 401 - Invaild input parameter. * @throws { BusinessError } 17100001 - Init error. * The WebviewController must be associted with a Web component. - * @throws { BusinessError } 17100007 - Invalid back or forward operation. * * @since 9 */ @@ -809,7 +792,7 @@ declare namespace webview { * * @since 9 */ - stop(); + stop(): void; /** * Registers the JavaScript object and method list. diff --git a/api/@ohos.wifi.d.ts b/api/@ohos.wifi.d.ts index 5636e3110121437abd1d637acd57d68a346c4f96..476684b65d664608c05404ca09507d42084757b6 100644 --- a/api/@ohos.wifi.d.ts +++ b/api/@ohos.wifi.d.ts @@ -31,6 +31,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.enableWifi */ function enableWifi(): boolean; @@ -43,6 +45,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.disableWifi */ function disableWifi(): boolean; @@ -54,6 +58,8 @@ declare namespace wifi { * @since 6 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.isWifiActive */ function isWifiActive(): boolean; @@ -67,6 +73,8 @@ declare namespace wifi { * @since 6 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.scan */ function scan(): boolean; @@ -78,21 +86,12 @@ declare namespace wifi { * @since 6 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getScanResults */ 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 Wi-Fi connection configuration to the device. * @@ -105,6 +104,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.addDeviceConfig */ function addDeviceConfig(config: WifiDeviceConfig): Promise; function addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; @@ -120,6 +121,7 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.addCandidateConfig */ function addUntrustedConfig(config: WifiDeviceConfig): Promise; function addUntrustedConfig(config: WifiDeviceConfig, callback: AsyncCallback): void; @@ -134,68 +136,11 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.removeCandidateConfig */ 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. - * - * @param config - candidate config. - * @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. - * - * @param networkId - Network ID which will be removed. - * @throws {ErrorCode} when failed to remove the hotspot configuration. - * @return {@code true} if the candidate hotspot configuration is removed, returns {@code false} otherwise. - * - * @since 9 - * @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 networkId - Network ID which will be connected. - * @throws {ErrCode} if operation is failed. - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - * @permission ohos.permission.SET_WIFI_INFO - */ - function connectToCandidateConfig(networkId: number): void; - /** * Connects to Wi-Fi network. * @@ -206,6 +151,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.connectToNetwork */ function connectToNetwork(networkId: number): boolean; @@ -220,6 +167,8 @@ declare namespace wifi { * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG and * ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.connectToDevice */ function connectToDevice(config: WifiDeviceConfig): boolean; @@ -232,6 +181,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.disconnect */ function disconnect(): boolean; @@ -245,6 +196,8 @@ declare namespace wifi { * @since 6 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getSignalLevel */ function getSignalLevel(rssi: number, band: number): number; @@ -255,6 +208,8 @@ declare namespace wifi { * @since 6 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getLinkedInfo */ function getLinkedInfo(): Promise; function getLinkedInfo(callback: AsyncCallback): void; @@ -266,6 +221,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.isConnected */ function isConnected(): boolean; @@ -279,6 +236,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.Core * @permission ohos.permission.GET_WIFI_INFO * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getSupportedFeatures */ function getSupportedFeatures(): number; @@ -290,6 +249,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.Core * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.isFeatureSupported */ function isFeatureSupported(featureId: number): boolean; @@ -303,6 +264,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_LOCAL_MAC and ohos.permission.GET_WIFI_INFO * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getDeviceMacAddress */ function getDeviceMacAddress(): string[]; @@ -315,6 +278,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getIpInfo */ function getIpInfo(): IpInfo; @@ -325,6 +290,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.Core * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getCountryCode */ function getCountryCode(): string; @@ -336,6 +303,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.reassociate */ function reassociate(): boolean; @@ -347,6 +316,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.reconnect */ function reconnect(): boolean; @@ -360,6 +331,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION and ohos.permission.GET_WIFI_CONFIG * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getDeviceConfigs */ function getDeviceConfigs(): Array; @@ -374,6 +347,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.updateNetwork */ function updateNetwork(config: WifiDeviceConfig): number; @@ -388,6 +363,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.disableNetwork */ function disableNetwork(netId: number): boolean; @@ -400,6 +377,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.removeAllNetwork */ function removeAllNetwork(): boolean; @@ -417,6 +396,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.removeDevice */ function removeDevice(id: number): boolean; @@ -430,6 +411,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.enableHotspot */ function enableHotspot(): boolean; @@ -443,6 +426,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.disableHotspot */ function disableHotspot(): boolean; @@ -454,6 +439,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.isHotspotDualBandSupported */ function isHotspotDualBandSupported(): boolean; @@ -465,6 +452,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.GET_WIFI_INFO * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.isHotspotActive */ function isHotspotActive(): boolean; @@ -481,6 +470,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.setHotspotConfig */ function setHotspotConfig(config: HotspotConfig): boolean; @@ -492,6 +483,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getHotspotConfig */ function getHotspotConfig(): HotspotConfig; @@ -505,6 +498,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION and ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getStations */ function getStations(): Array; @@ -515,6 +510,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getP2pLinkedInfo */ function getP2pLinkedInfo(): Promise; function getP2pLinkedInfo(callback: AsyncCallback): void; @@ -526,6 +523,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getCurrentGroup */ function getCurrentGroup(): Promise; function getCurrentGroup(callback: AsyncCallback): void; @@ -537,24 +536,12 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.getP2pPeerDevices */ 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. * @@ -563,6 +550,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.createGroup */ function createGroup(config: WifiP2PConfig): boolean; @@ -573,6 +562,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.removeGroup */ function removeGroup(): boolean; @@ -584,6 +575,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.p2pConnect */ function p2pConnect(config: WifiP2PConfig): boolean; @@ -594,6 +587,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.p2pDisonnect */ function p2pCancelConnect(): boolean; @@ -604,6 +599,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.startDiscoverDevices */ function startDiscoverDevices(): boolean; @@ -614,6 +611,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.stopDiscoverDevices */ function stopDiscoverDevices(): boolean; @@ -626,21 +625,11 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.deletePersistentGroup */ function deletePersistentGroup(netId: number): boolean; - /** - * Obtains information about the groups. - * - * @return Returns the groups information. - * @since 9 - * @syscap SystemCapability.Communication.WiFi.P2P - * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION - * @systemapi Hide this for inner system use. - */ - function getP2pGroups(): Promise>; - function getP2pGroups(callback: AsyncCallback>): void; - /** * Sets the name of the Wi-Fi P2P device. * @@ -650,6 +639,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.setDeviceName */ function setDeviceName(devName: string): boolean; @@ -660,6 +651,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:wifiStateChange */ function on(type: "wifiStateChange", callback: Callback): void; @@ -671,6 +664,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:wifiStateChange */ function off(type: "wifiStateChange", callback?: Callback): void; @@ -681,6 +676,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:wifiConnectionChange */ function on(type: "wifiConnectionChange", callback: Callback): void; @@ -692,6 +689,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:wifiConnectionChange */ function off(type: "wifiConnectionChange", callback?: Callback): void; @@ -702,6 +701,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:wifiScanStateChange */ function on(type: "wifiScanStateChange", callback: Callback): void; @@ -713,6 +714,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:wifiScanStateChange */ function off(type: "wifiScanStateChange", callback?: Callback): void; @@ -723,6 +726,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:wifiRssiChange */ function on(type: "wifiRssiChange", callback: Callback): void; @@ -734,6 +739,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:wifiRssiChange */ function off(type: "wifiRssiChange", callback?: Callback): void; @@ -745,6 +752,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:streamChange */ function on(type: "streamChange", callback: Callback): void; @@ -757,31 +766,11 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.STA * @permission ohos.permission.MANAGE_WIFI_CONNECTION * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:streamChange */ function off(type: "streamChange", callback?: Callback): void; - /** - * Subscribe Wi-Fi device config change events. - * - * @return Returns 0: config is added, 1: config is changed, 2: config is removed. - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - * @permission ohos.permission.GET_WIFI_INFO - * @systemapi Hide this for inner system use. - */ - function on(type: "deviceConfigChange", callback: Callback): void; - - /** - * Subscribe Wi-Fi device config change events. - * - * @return Returns 0: config is added, 1: config is changed, 2: config is removed. - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - * @permission ohos.permission.GET_WIFI_INFO - * @systemapi Hide this for inner system use. - */ - function off(type: "deviceConfigChange", callback?: Callback): void; - /** * Subscribe Wi-Fi hotspot state change events. * @@ -789,6 +778,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:hotspotStateChange */ function on(type: "hotspotStateChange", callback: Callback): void; @@ -800,6 +791,8 @@ declare namespace wifi { * @since 7 * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:hotspotStateChange */ function off(type: "hotspotStateChange", callback?: Callback): void; @@ -811,6 +804,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:hotspotStaJoin */ function on(type: "hotspotStaJoin", callback: Callback): void; @@ -823,6 +818,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:hotspotStaJoin */ function off(type: "hotspotStaJoin", callback?: Callback): void; @@ -834,6 +831,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:hotspotStaLeave */ function on(type: "hotspotStaLeave", callback: Callback): void; @@ -845,6 +844,8 @@ declare namespace wifi { * @syscap SystemCapability.Communication.WiFi.AP.Core * @permission ohos.permission.MANAGE_WIFI_HOTSPOT * @systemapi Hide this for inner system use. + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:hotspotStaLeave */ function off(type: "hotspotStaLeave", callback?: Callback): void; @@ -855,6 +856,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:p2pStateChange */ function on(type: "p2pStateChange", callback: Callback): void; @@ -864,6 +867,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:p2pStateChange */ function off(type: "p2pStateChange", callback?: Callback): void; @@ -874,6 +879,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:p2pConnectionChange */ function on(type: "p2pConnectionChange", callback: Callback): void; @@ -883,6 +890,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:p2pConnectionChange */ function off(type: "p2pConnectionChange", callback?: Callback): void; @@ -893,6 +902,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:p2pDeviceChange */ function on(type: "p2pDeviceChange", callback: Callback): void; @@ -903,6 +914,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:p2pDeviceChange */ function off(type: "p2pDeviceChange", callback?: Callback): void; @@ -913,6 +926,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:p2pPeerDeviceChange */ function on(type: "p2pPeerDeviceChange", callback: Callback): void; @@ -922,6 +937,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.LOCATION + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:p2pPeerDeviceChange */ function off(type: "p2pPeerDeviceChange", callback?: Callback): void; @@ -932,6 +949,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:p2pPersistentGroupChange */ function on(type: "p2pPersistentGroupChange", callback: Callback): void; @@ -941,6 +960,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:p2pPersistentGroupChange */ function off(type: "p2pPersistentGroupChange", callback?: Callback): void; @@ -951,6 +972,8 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.on#event:p2pDiscoveryChange */ function on(type: "p2pDiscoveryChange", callback: Callback): void; @@ -960,99 +983,18 @@ declare namespace wifi { * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P * @permission ohos.permission.GET_WIFI_INFO + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.off#event:p2pDiscoveryChange */ function off(type: "p2pDiscoveryChange", callback?: Callback): void; - /** - * Wi-Fi EAP method. - * - * @since 9 - * @systemapi Hide this for inner system use. - * @syscap SystemCapability.Communication.WiFi.STA - */ - enum EapMethod { - EAP_NONE, - EAP_PEAP, - EAP_TLS, - EAP_TTLS, - EAP_PWD, - EAP_SIM, - EAP_AKA, - EAP_AKA_PRIME, - EAP_UNAUTH_TLS, - } - - /** - * Wi-Fi phase 2 method. - * - * @since 9 - * @systemapi Hide this for inner system use. - * @syscap SystemCapability.Communication.WiFi.STA - */ - enum Phase2Method { - PHASE2_NONE, - PHASE2_PAP, - PHASE2_MSCHAP, - PHASE2_MSCHAPV2, - PHASE2_GTC, - PHASE2_SIM, - PHASE2_AKA, - PHASE2_AKA_PRIME, - } - - /** - * Wi-Fi EAP config. - * - * @since 9 - * @systemapi Hide this for inner system use. - * @syscap SystemCapability.Communication.WiFi.STA - */ - interface WifiEapConfig { - /** EAP authentication method */ - eapMethod: EapMethod; - - /** Phase 2 authentication method */ - phase2Method: Phase2Method; - - /** The identity */ - identity: string; - - /** Anonymous identity */ - anonymousIdentity: string; - - /** Password */ - password: string; - - /** CA certificate alias */ - caCertAliases: string; - - /** CA certificate path */ - caPath: string; - - /** Client certificate alias */ - clientCertAliases: string; - - /** Alternate subject match */ - altSubjectMatch: string; - - /** Domain suffix match */ - domainSuffixMatch: string; - - /** Realm for Passpoint credential */ - realm: string; - - /** Public Land Mobile Network of the provider of Passpoint credential */ - plmn: string; - - /** Sub ID of the SIM card */ - eapSubId: number; - } - /** * Wi-Fi device configuration information. * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiDeviceConfig */ interface WifiDeviceConfig { /** Wi-Fi SSID: the maximum length is 32 */ @@ -1097,15 +1039,6 @@ declare namespace wifi { /** IP config of static */ /* @systemapi */ staticIp: IpConfig; - - /** - * EAP config info. - * - * @since 9 - * @systemapi - * @syscap SystemCapability.Communication.WiFi.STA - */ - eapConfig: WifiEapConfig; } /** @@ -1114,6 +1047,8 @@ declare namespace wifi { * @since 7 * @systemapi Hide this for inner system use. * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.IpConfig */ interface IpConfig { ipAddress: number; @@ -1122,40 +1057,13 @@ declare namespace wifi { domains: Array; } - /** - * Wi-Fi information elements. - * - * @since 9 - * @systemapi Hide this for inner system use. - * @syscap SystemCapability.Communication.WiFi.STA - */ - interface WifiInfoElem { - /** Element id */ - eid: number; - /** Element content */ - content: Uint8Array; - } - - /** - * 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 + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiScanInfo */ interface WifiScanInfo { /** Wi-Fi SSID: the maximum length is 32 */ @@ -1182,30 +1090,6 @@ declare namespace wifi { /** Channel width */ channelWidth: number; - /** - * Center frequency 0. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - */ - centerFrequency0: number; - - /** - * Center frequency 1. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - */ - centerFrequency1: number; - - /** - * Information elements. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - */ - infoElems: Array; - /** Time stamp */ timestamp: number; } @@ -1215,6 +1099,8 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.Core + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiSecurityType */ enum WifiSecurityType { /** Invalid security type */ @@ -1231,46 +1117,6 @@ declare namespace wifi { /** Simultaneous Authentication of Equals (SAE) */ WIFI_SEC_TYPE_SAE = 4, - - /** - * EAP authentication. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.Core - */ - WIFI_SEC_TYPE_EAP = 5, - - /** - * SUITE_B_192 192 bit level. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.Core - */ - WIFI_SEC_TYPE_EAP_SUITE_B = 6, - - /** - * Opportunististic Wireless Encryption. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.Core - */ - WIFI_SEC_TYPE_OWE = 7, - - /** - * WAPI certificate to be specified. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.Core - */ - WIFI_SEC_TYPE_WAPI_CERT = 8, - - /** - * WAPI pre-shared key to be specified. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.Core - */ - WIFI_SEC_TYPE_WAPI_PSK = 9, } /** @@ -1278,6 +1124,8 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiLinkedInfo */ interface WifiLinkedInfo { /** The SSID of the Wi-Fi hotspot */ @@ -1316,14 +1164,6 @@ declare namespace wifi { /* @systemapi */ snr: number; - /** - * Type of macAddress: 0 - real mac, 1 - random mac. - * - * @since 9 - * @syscap SystemCapability.Communication.WiFi.STA - */ - macType: number; - /** The Wi-Fi MAC address of a device. */ macAddress: string; @@ -1343,6 +1183,8 @@ declare namespace wifi { * * @since 7 * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.IpInfo */ interface IpInfo { /** The IP address of the Wi-Fi connection */ @@ -1373,6 +1215,8 @@ declare namespace wifi { * @since 7 * @systemapi Hide this for inner system use. * @syscap SystemCapability.Communication.WiFi.AP.Core + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.HotspotConfig */ interface HotspotConfig { /** The SSID of the Wi-Fi hotspot */ @@ -1397,6 +1241,8 @@ declare namespace wifi { * @since 7 * @systemapi Hide this for inner system use. * @syscap SystemCapability.Communication.WiFi.AP.Core + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.StationInfo */ interface StationInfo { /** the network name of the Wi-Fi client */ @@ -1415,6 +1261,8 @@ declare namespace wifi { * @since 7 * @systemapi Hide this for inner system use. * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.IpType */ enum IpType { /** Use statically configured IP settings */ @@ -1433,6 +1281,8 @@ declare namespace wifi { * @since 6 * @systemapi Hide this for inner system use. * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.SuppState */ export enum SuppState { /** The supplicant is not associated with or is disconnected from the AP. */ @@ -1477,6 +1327,8 @@ declare namespace wifi { * * @since 6 * @syscap SystemCapability.Communication.WiFi.STA + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.ConnState */ export enum ConnState { /** The device is searching for an available AP. */ @@ -1509,6 +1361,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiP2pDevice */ interface WifiP2pDevice { /** Device name */ @@ -1532,6 +1386,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiP2PConfig */ interface WifiP2PConfig { /** Device mac address */ @@ -1558,6 +1414,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiP2pGroupInfo */ interface WifiP2pGroupInfo { /** Indicates whether it is group owner */ @@ -1593,6 +1451,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.P2pConnectState */ enum P2pConnectState { DISCONNECTED = 0, @@ -1604,6 +1464,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.WifiP2pLinkedInfo */ interface WifiP2pLinkedInfo { /** Connection status */ @@ -1621,6 +1483,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.P2pDeviceStatus */ enum P2pDeviceStatus { CONNECTED = 0, @@ -1635,6 +1499,8 @@ declare namespace wifi { * * @since 8 * @syscap SystemCapability.Communication.WiFi.P2P + * @deprecated since 9 + * @useinstead ohos.wifiManager/wifiManager.GroupOwnerBand */ enum GroupOwnerBand { GO_BAND_AUTO = 0, diff --git a/api/@ohos.wifiManager.d.ts b/api/@ohos.wifiManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee9bdc6388bb5b1a8eb60320c46cfeea45fea128 --- /dev/null +++ b/api/@ohos.wifiManager.d.ts @@ -0,0 +1,1920 @@ +/* + * 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 Wi-Fi. + * + * @since 9 + * @import import wifiManager from '@ohos.wifiManager'; + */ +declare namespace wifiManager { + /** + * Enables Wi-Fi. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501003 - Failed for wifi is closing. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function enableWifi(): void; + + /** + * Disables Wi-Fi. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501004 - Failed for wifi is opening. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function disableWifi(): void; + + /** + * Queries the Wi-Fi status + * + * @return Returns {@code true} if the Wi-Fi is active, returns {@code false} otherwise. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION + */ + function scan(): void; + + /** + * Obtains the hotspot information that scanned. + * + * @return Returns information about scanned Wi-Fi hotspots if any. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) + */ + function getScanResults(): Promise>; + function getScanResults(callback: AsyncCallback>): void; + + /** + * Obtains the scanned results. + * + * @return Returns information about scanned Wi-Fi hotspots if any. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or ohos.permission.LOCATION) + */ + function getScanResultsSync(): Array; + + /** + * Adds Wi-Fi connection configuration to the device. + * + *

          The configuration will be updated when the configuration is added.

          + * + * @param config Indicates the device configuration for connection to the Wi-Fi network. + * @return Returns {@code networkId} if the configuration is added; returns {@code -1} otherwise. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG + * @systemapi Hide this for inner system use. + */ + function addDeviceConfig(config: WifiDeviceConfig): Promise; + function addDeviceConfig(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. + * + * @param config - candidate config. + * @return Returns {@code networkId} if the configuration is added; returns {@code -1} otherwise. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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. + * + * @param networkId - Network ID which will be removed. + * @throws {ErrorCode} when failed to remove the hotspot configuration. + * @return {@code true} if the candidate hotspot configuration is removed, returns {@code false} otherwise. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 networkId - Network ID which will be connected. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO + */ + function connectToCandidateConfig(networkId: number): void; + + /** + * Connects to Wi-Fi network. + * + * @param networkId ID of the connected network. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function connectToNetwork(networkId: number): void; + + /** + * Connects to Wi-Fi network. + * + * @param config Indicates the device configuration for connection to the Wi-Fi network. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG and + * ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function connectToDevice(config: WifiDeviceConfig): void; + + /** + * Disconnects Wi-Fi network. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function disconnect(): boolean; + + /** + * 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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @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. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function isConnected(): boolean; + + /** + * Obtains the features supported by this device. + * + *

          To check whether this device supports a specified feature. + * + * @return Returns the features supported by this device. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2401000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO + * @systemapi Hide this for inner system use. + */ + function getSupportedFeatures(): number; + + /** + * 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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2401000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function isFeatureSupported(featureId: number): boolean; + + /** + * Obtains the MAC address of a Wi-Fi device. Wi-Fi must be enabled. + * + *

          The MAC address is unique and cannot be changed. + * + * @return Returns the MAC address of the Wi-Fi device. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_LOCAL_MAC and ohos.permission.GET_WIFI_INFO + * @systemapi Hide this for inner system use. + */ + function getDeviceMacAddress(): string[]; + + /** + * 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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2401000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function getCountryCode(): string; + + /** + * Re-associates to current network. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function reassociate(): void; + + /** + * Re-connects to current network. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @throws {BusinessError} 2501001 - Wifi is closed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function reconnect(): void; + + /** + * Obtains the list of all existing Wi-Fi configurations. + * + *

          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 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION and ohos.permission.GET_WIFI_CONFIG + * @systemapi Hide this for inner system use. + */ + function getDeviceConfigs(): Array; + + /** + * Updates the specified Wi-Fi configuration. + * + * @param config Indicates the Wi-Fi configuration to update. + * + * @return Returns the network ID in the updated Wi-Fi configuration if the update is successful; + * returns {@code -1} if the specified Wi-Fi configuration is not contained in the list. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG + * @systemapi Hide this for inner system use. + */ + function updateNetwork(config: WifiDeviceConfig): number; + + /** + * Disables a specified network. + * + *

          The disabled network will not be associated with again. + * + * @param netId Identifies the network to disable. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function disableNetwork(netId: number): void; + + /** + * Removes all the saved Wi-Fi configurations. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function removeAllNetwork(): void; + + /** + * Deletes a Wi-Fi network with a specified ID. + * + *

          After a Wi-Fi network is deleted, its configuration will be deleted from the list of Wi-Fi configurations. + * If the Wi-Fi network is being connected, the connection will be interrupted. + * The application can only delete Wi-Fi networks it has created. + * + * @param id Indicates the ID of the Wi-Fi network, + * which can be obtained using the {@link #addDeviceConfig} or {@link #getLinkedInfo} method. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function removeDevice(id: number): void; + + /** + * Enables a Wi-Fi hotspot. + * + *

          This method is asynchronous. After the Wi-Fi hotspot is enabled, Wi-Fi may be disabled. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function enableHotspot(): void; + + /** + * Disables a Wi-Fi hotspot. + * + *

          This method is asynchronous. If Wi-Fi is enabled after the Wi-Fi hotspot is disabled, Wi-Fi may be re-enabled. + * + * @return Returns {@code true} if this method is called successfully, returns {@code false} otherwise. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function disableHotspot(): void; + + /** + * Checks whether a device serving as a Wi-Fi hotspot supports both the 2.4 GHz and 5 GHz Wi-Fi. + * + * @return Returns {@code true} if the method is called successfully, returns {@code false} otherwise. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function isHotspotDualBandSupported(): boolean; + + /** + * Checks whether Wi-Fi hotspot is active on a device. + * + * @return Returns {@code true} if Wi-Fi hotspot is enabled, returns {@code false} otherwise. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO + * @systemapi Hide this for inner system use. + */ + function isHotspotActive(): boolean; + + /** + * Sets the hotspot for a device. + * + *

          Only OPEN and WPA2 PSK hotspots can be configured. + * + * @param config Indicates the Wi-Fi hotspot configuration. + * The SSID and {@code securityType} must be available and correct. + * If {@code securityType} is not {@code open}, {@code preSharedKey} must be available and correct. + * @return Returns {@code true} if the method is called successfully, returns {@code false} otherwise. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG + * @systemapi Hide this for inner system use. + */ + function setHotspotConfig(config: HotspotConfig): void; + + /** + * Obtains the Wi-Fi hotspot configuration. + * + * @return Returns the configuration of an existing or enabled Wi-Fi hotspot. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG + * @systemapi Hide this for inner system use. + */ + function getHotspotConfig(): HotspotConfig; + + /** + * Obtains the list of clients that are connected to a Wi-Fi hotspot. + * + *

          This method can only be used on a device that serves as a Wi-Fi hotspot. + * + * @return Returns the list of clients that are connected to the Wi-Fi hotspot. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION and ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function getStations(): Array; + + /** + * Obtains information about a P2P connection. + * + * @return Returns the P2P connection information. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function createGroup(config: WifiP2PConfig): void; + + /** + * Removes a P2P group. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function removeGroup(): void; + + /** + * Initiates a P2P connection to a device with the specified configuration. + * + * @param config Indicates the configuration for connecting to a specific group. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function p2pConnect(config: WifiP2PConfig): void; + + /** + * Disconnects a P2P connection. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function p2pDisconnect(): void; + + /** + * Discovers Wi-Fi P2P devices. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + */ + function startDiscoverDevices(): void; + + /** + * Stops discovering Wi-Fi P2P devices. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function stopDiscoverDevices(): void; + + /** + * Deletes the persistent P2P group with the specified network ID. + * + * @param netId Indicates the network ID of the group to be deleted. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function deletePersistentGroup(netId: number): void; + + /** + * Obtains information about the groups. + * + * @return Returns the groups information. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO and ohos.permission.LOCATION + * @systemapi Hide this for inner system use. + */ + function getP2pGroups(): Promise>; + function getP2pGroups(callback: AsyncCallback>): void; + + /** + * Sets the name of the Wi-Fi P2P device. + * + * @param devName Indicates the name to be set. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function setDeviceName(devName: string): void; + + /** + * Subscribe Wi-Fi status change events. + * + * @return Returns 0: inactive, 1: active, 2: activating, 3: deactivating + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "wifiRssiChange", callback?: Callback): void; + + /** + * Subscribe Wi-Fi stream change events. + * + * @return Returns 0: stream none, 1: stream down, 2: stream up, 3: stream bidirectional + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function on(type: "streamChange", callback: Callback): void; + + /** + * Unsubscribe Wi-Fi stream change events. + * + *

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

          + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.MANAGE_WIFI_CONNECTION + * @systemapi Hide this for inner system use. + */ + function off(type: "streamChange", callback?: Callback): void; + + /** + * Subscribe Wi-Fi device config change events. + * + * @return Returns 0: config is added, 1: config is changed, 2: config is removed. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + * @systemapi Hide this for inner system use. + */ + function on(type: "deviceConfigChange", callback: Callback): void; + + /** + * Subscribe Wi-Fi device config change events. + * + * @return Returns 0: config is added, 1: config is changed, 2: config is removed. + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2501000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.STA + * @permission ohos.permission.GET_WIFI_INFO + * @systemapi Hide this for inner system use. + */ + function off(type: "deviceConfigChange", callback?: Callback): void; + + /** + * Subscribe Wi-Fi hotspot state change events. + * + * @return Returns 0: inactive, 1: active, 2: activating, 3: deactivating + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "hotspotStateChange", callback?: Callback): void; + + /** + * Subscribe Wi-Fi hotspot sta join events. + * + * @return Returns StationInfo + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function on(type: "hotspotStaJoin", callback: Callback): void; + + /** + * Unsubscribe Wi-Fi hotspot sta join events. + * + *

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

          + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function off(type: "hotspotStaJoin", callback?: Callback): void; + + /** + * Subscribe Wi-Fi hotspot sta leave events. + * + * @return Returns {@link #StationInfo} object + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function on(type: "hotspotStaLeave", callback: Callback): void; + + /** + * Unsubscribe Wi-Fi hotspot sta leave events. + * + * @return Returns {@link #StationInfo} object + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 202 - System API is not allowed called by third HAP. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2601000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.AP.Core + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT + * @systemapi Hide this for inner system use. + */ + function off(type: "hotspotStaLeave", callback?: Callback): void; + + /** + * Subscribe P2P status change events. + * + * @return Returns 1: idle, 2: starting, 3:started, 4: closing, 5: closed + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pStateChange", callback: Callback): void; + + /** + * Unsubscribe P2P status change events. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pConnectionChange", callback: Callback): void; + + /** + * Unsubscribe P2P connection change events. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function on(type: "p2pDiscoveryChange", callback: Callback): void; + + /** + * Unsubscribe P2P discovery events. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 401 - Invalid parameters. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2801000 - Operation failed. + * @syscap SystemCapability.Communication.WiFi.P2P + * @permission ohos.permission.GET_WIFI_INFO + */ + function off(type: "p2pDiscoveryChange", callback?: Callback): void; + + /** + * Wi-Fi EAP method. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.STA + */ + enum EapMethod { + EAP_NONE, + EAP_PEAP, + EAP_TLS, + EAP_TTLS, + EAP_PWD, + EAP_SIM, + EAP_AKA, + EAP_AKA_PRIME, + EAP_UNAUTH_TLS, + } + + /** + * Wi-Fi phase 2 method. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.STA + */ + enum Phase2Method { + PHASE2_NONE, + PHASE2_PAP, + PHASE2_MSCHAP, + PHASE2_MSCHAPV2, + PHASE2_GTC, + PHASE2_SIM, + PHASE2_AKA, + PHASE2_AKA_PRIME, + } + + /** + * Wi-Fi EAP config. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface WifiEapConfig { + /** EAP authentication method */ + eapMethod: EapMethod; + + /** Phase 2 authentication method */ + phase2Method: Phase2Method; + + /** The identity */ + identity: string; + + /** Anonymous identity */ + anonymousIdentity: string; + + /** Password */ + password: string; + + /** CA certificate alias */ + caCertAliases: string; + + /** CA certificate path */ + caPath: string; + + /** Client certificate alias */ + clientCertAliases: string; + + /** Alternate subject match */ + altSubjectMatch: string; + + /** Domain suffix match */ + domainSuffixMatch: string; + + /** Realm for Passpoint credential */ + realm: string; + + /** Public Land Mobile Network of the provider of Passpoint credential */ + plmn: string; + + /** Sub ID of the SIM card */ + eapSubId: number; + } + + /** + * Wi-Fi device configuration information. + * + * @since 9 + * @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; + + /** The UID of the Wi-Fi configuration creator */ + /* @systemapi */ + creatorUid: number; + + /** Disable reason */ + /* @systemapi */ + disableReason: number; + + /** Allocated networkId */ + /* @systemapi */ + netId: number; + + /** Random mac type */ + /* @systemapi */ + randomMacType: number; + + /** Random mac address, the length is 6 */ + /* @systemapi */ + randomMacAddr: string; + + /** IP Type */ + /* @systemapi */ + ipType: IpType; + + /** IP config of static */ + /* @systemapi */ + staticIp: IpConfig; + + /** + * EAP config info. + * @systemapi + */ + eapConfig: WifiEapConfig; + } + + /** + * Wi-Fi IP configuration information. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface IpConfig { + ipAddress: number; + gateway: number; + prefixLength: number; + dnsServers: number[]; + domains: Array; + } + + /** + * Wi-Fi information elements. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + */ + interface WifiInfoElem { + /** Element id */ + eid: number; + /** Element content */ + content: Uint8Array; + } + + /** + * 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 9 + * @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 0. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + */ + centerFrequency0: number; + + /** + * Center frequency 1. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + */ + centerFrequency1: number; + + /** + * Information elements. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + */ + infoElems: Array; + + /** Time stamp */ + timestamp: number; + } + + /** + * Describes the wifi security type. + * + * @since 9 + * @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. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.Core + */ + WIFI_SEC_TYPE_EAP = 5, + + /** + * SUITE_B_192 192 bit level. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.Core + */ + WIFI_SEC_TYPE_EAP_SUITE_B = 6, + + /** + * Opportunististic Wireless Encryption. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.Core + */ + WIFI_SEC_TYPE_OWE = 7, + + /** + * WAPI certificate to be specified. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.Core + */ + WIFI_SEC_TYPE_WAPI_CERT = 8, + + /** + * WAPI pre-shared key to be specified. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.Core + */ + WIFI_SEC_TYPE_WAPI_PSK = 9, + } + + /** + * Wi-Fi connection information. + * + * @since 9 + * @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 ID(uniquely identifies) of a Wi-Fi connection. */ + /* @systemapi */ + networkId: number; + + /** 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; + + /** The load value of this Wi-Fi connection. A greater value indicates a higher load. */ + /* @systemapi */ + chload: number; + + /** The signal-to-noise ratio (SNR) of this Wi-Fi connection. */ + /* @systemapi */ + snr: number; + + /** + * Type of macAddress: 0 - real mac, 1 - random mac. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.STA + */ + 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 the supplicant of this Wi-Fi connection. */ + /* @systemapi */ + suppState: SuppState; + + /** The state of this Wi-Fi connection. */ + connState: ConnState; + } + + /** + * Wi-Fi IP information. + * + * @since 9 + * @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; + } + + /** + * Wi-Fi hotspot configuration information. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.AP.Core + */ + interface HotspotConfig { + /** The SSID of the Wi-Fi hotspot */ + ssid: string; + + /** The encryption mode of the Wi-Fi hotspot */ + securityType: WifiSecurityType; + + /** The frequency band of the Wi-Fi hotspot */ + band: number; + + /** The password of the Wi-Fi hotspot */ + preSharedKey: string; + + /** The maximum number of connections allowed by the Wi-Fi hotspot */ + maxConn: number; + } + + /** + * Wi-Fi station information. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.AP.Core + */ + interface StationInfo { + /** the network name of the Wi-Fi client */ + name: string; + + /** The MAC address of the Wi-Fi client */ + macAddress: string; + + /** The IP address of the Wi-Fi client */ + ipAddress: string; + } + + /** + * Wi-Fi IP type enumeration. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.STA + */ + enum IpType { + /** Use statically configured IP settings */ + STATIC, + + /** Use dynamically configured IP settings */ + DHCP, + + /** No IP details are assigned */ + UNKNOWN, + } + + /** + * The state of the supplicant enumeration. + * + * @since 9 + * @systemapi Hide this for inner system use. + * @syscap SystemCapability.Communication.WiFi.STA + */ + export enum SuppState { + /** The supplicant is not associated with or is disconnected from the AP. */ + DISCONNECTED, + + /** The network interface is disabled. */ + INTERFACE_DISABLED, + + /** The supplicant is disabled. */ + INACTIVE, + + /** The supplicant is scanning for a Wi-Fi connection. */ + SCANNING, + + /** The supplicant is authenticating with a specified AP. */ + AUTHENTICATING, + + /** The supplicant is associating with a specified AP. */ + ASSOCIATING, + + /** The supplicant is associated with a specified AP. */ + ASSOCIATED, + + /** The four-way handshake is ongoing. */ + FOUR_WAY_HANDSHAKE, + + /** The group handshake is ongoing. */ + GROUP_HANDSHAKE, + + /** All authentication is completed. */ + COMPLETED, + + /** Failed to establish a connection to the supplicant. */ + UNINITIALIZED, + + /** The supplicant is in an unknown or invalid state. */ + INVALID + } + + /** + * The state of Wi-Fi connection enumeration. + * + * @since 9 + * @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 9 + * @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 capabilities */ + groupCapabilities: number; + } + + /** + * P2P config. + * + * @since 9 + * @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 9 + * @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 9 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + enum P2pConnectState { + DISCONNECTED = 0, + CONNECTED = 1, + } + + /** + * P2P linked information. + * + * @since 9 + * @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 9 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + enum P2pDeviceStatus { + CONNECTED = 0, + INVITED = 1, + FAILED = 2, + AVAILABLE = 3, + UNAVAILABLE = 4, + } + + /** + * P2P group owner band. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.P2P + */ + enum GroupOwnerBand { + GO_BAND_AUTO = 0, + GO_BAND_2GHZ = 1, + GO_BAND_5GHZ = 2, + } +} + +export default wifiManager; diff --git a/api/@ohos.wifiManagerExt.d.ts b/api/@ohos.wifiManagerExt.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc4f43a272340497af40c0f8669d1eead28a4cab --- /dev/null +++ b/api/@ohos.wifiManagerExt.d.ts @@ -0,0 +1,113 @@ +/* + * 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 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 9 + * @import import wifiManagerExt from '@ohos.wifiManagerExt'; + */ +declare namespace wifiManagerExt { + /** + * Enables a Wi-Fi hotspot. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2701000 - Operation failed. + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function enableHotspot(): void; + + /** + * Disables a Wi-Fi hotspot. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2701000 - Operation failed. + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function disableHotspot(): void; + + /** + * Obtains the supported power Mode. + * + * @return Returns the array of supported power Mode. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2701000 - Operation failed. + * @permission ohos.permission.GET_WIFI_INFO + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function getSupportedPowerMode(): Promise>; + function getSupportedPowerMode(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 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2701000 - Operation failed. + * @permission ohos.permission.GET_WIFI_INFO + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function getPowerMode (): Promise; + function getPowerMode (callback: AsyncCallback): void; + + /** + * Set the current Wi-Fi power mode. + * + * @since 9 + * @throws {BusinessError} 201 - Permission denied. + * @throws {BusinessError} 801 - Capability not supported. + * @throws {BusinessError} 2701000 - Operation failed. + * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + function setPowerMode(mode: PowerMode) : void + + /** + * The power Mode enumeration. + * + * @since 9 + * @syscap SystemCapability.Communication.WiFi.AP.Extension + */ + export enum PowerMode { + /** Sleeping Mode. */ + SLEEPING = 0, + + /** General Mode. */ + GENERAL = 1, + + /** Through wall Mode. */ + THROUGH_WALL = 2, + } +} + +export default wifiManagerExt; diff --git a/api/@ohos.wifiext.d.ts b/api/@ohos.wifiext.d.ts index c881d0a13205b7a00ad5d80cd7806731309a4680..1b6f7296dfff3445e34d21b577a4875f3abc0a13 100644 --- a/api/@ohos.wifiext.d.ts +++ b/api/@ohos.wifiext.d.ts @@ -33,6 +33,8 @@ declare namespace wifiext { * @since 8 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT * @syscap SystemCapability.Communication.WiFi.AP.Extension + * @deprecated since 9 + * @useinstead ohos.wifiManagerExt/wifiManagerExt.enableHotspot */ function enableHotspot(): boolean; @@ -43,6 +45,8 @@ declare namespace wifiext { * @since 8 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT * @syscap SystemCapability.Communication.WiFi.AP.Extension + * @deprecated since 9 + * @useinstead ohos.wifiManagerExt/wifiManagerExt.disableHotspot */ function disableHotspot(): boolean; @@ -54,6 +58,8 @@ declare namespace wifiext { * @since 8 * @permission ohos.permission.GET_WIFI_INFO * @syscap SystemCapability.Communication.WiFi.AP.Extension + * @deprecated since 9 + * @useinstead ohos.wifiManagerExt/wifiManagerExt.getSupportedPowerMode */ function getSupportedPowerModel(): Promise>; function getSupportedPowerModel(callback: AsyncCallback>): void; @@ -66,6 +72,8 @@ declare namespace wifiext { * @since 8 * @permission ohos.permission.GET_WIFI_INFO * @syscap SystemCapability.Communication.WiFi.AP.Extension + * @deprecated since 9 + * @useinstead ohos.wifiManagerExt/wifiManagerExt.getPowerMode */ function getPowerModel (): Promise; function getPowerModel (callback: AsyncCallback): void; @@ -78,6 +86,8 @@ declare namespace wifiext { * @since 8 * @permission ohos.permission.MANAGE_WIFI_HOTSPOT_EXT * @syscap SystemCapability.Communication.WiFi.AP.Extension + * @deprecated since 9 + * @useinstead ohos.wifiManagerExt/wifiManagerExt.setPowerMode */ function setPowerModel(model: PowerModel) : boolean @@ -86,6 +96,8 @@ declare namespace wifiext { * * @since 8 * @syscap SystemCapability.Communication.WiFi.AP.Extension + * @deprecated since 9 + * @useinstead ohos.wifiManagerExt/wifiManagerExt.PowerMode */ export enum PowerModel { /** Sleeping model. */ diff --git a/api/@ohos.window.d.ts b/api/@ohos.window.d.ts index 1ea88ecd65c6f26a84031a10392aec2815f08535..09bc2a175039f2e400a9e6416fdb5c25f79707ad 100644 --- a/api/@ohos.window.d.ts +++ b/api/@ohos.window.d.ts @@ -615,7 +615,7 @@ declare namespace window { /** * Indicates Parent window id */ - parentId?: string + parentId?: number } /** @@ -627,7 +627,7 @@ declare namespace window { * @throws {BusinessError} 1300001 - If window has created * @throws {BusinessError} 1300006 - If window context is abnormally */ - function createWindow({ name, windowType, ctx, displayId, parentId = "" }: Configuration, callback: AsyncCallback): void; + function createWindow(config: Configuration, callback: AsyncCallback): void; /** * Create a window with a specific configuration @@ -638,7 +638,7 @@ declare namespace window { * @throws {BusinessError} 1300001 - If window has created * @throws {BusinessError} 1300006 - If window context is abnormally */ - function createWindow({ name, windowType, ctx, displayId, parentId = "" }: Configuration): Promise; + function createWindow(config: Configuration): Promise; /** * Create a sub window with a specific id and type, only support 7. @@ -1920,7 +1920,7 @@ declare namespace window { * @throws {BusinessError} 201 - If there is no permission * @throws {BusinessError} 401 - If param is invalid * @throws {BusinessError} 1300002 - If window state is abnormally - * @permission ohos.permission.PRIVACE_WINDOW + * @permission ohos.permission.PRIVACY_WINDOW * @syscap SystemCapability.WindowManager.WindowManager.Core * @since 9 */ @@ -1932,7 +1932,7 @@ declare namespace window { * @throws {BusinessError} 201 - If there is no permission * @throws {BusinessError} 401 - If param is invalid * @throws {BusinessError} 1300002 - If window state is abnormally - * @permission ohos.permission.PRIVACE_WINDOW + * @permission ohos.permission.PRIVACY_WINDOW * @syscap SystemCapability.WindowManager.WindowManager.Core * @since 9 */ @@ -2148,10 +2148,10 @@ declare namespace window { * @StageModelOnly */ enum WindowStageEventType { - FOREGROUND = 1, + SHOWN = 1, ACTIVE, INACTIVE, - BACKGROUND, + HIDDEN, } /** * WindowStage diff --git a/api/@ohos.worker.d.ts b/api/@ohos.worker.d.ts index fffe7241f19c8401af8ed3339aae376fb07a5bbf..f1e54446fa3752fa104b2ba06a58e3201f03500b 100644 --- a/api/@ohos.worker.d.ts +++ b/api/@ohos.worker.d.ts @@ -67,7 +67,7 @@ export interface Event { * @since 7 * @syscap SystemCapability.Utils.Lang */ - export interface ErrorEvent extends Event { +export interface ErrorEvent extends Event { /** * Information about the exception. * @since 7 @@ -109,7 +109,7 @@ export interface Event { * @since 7 * @syscap SystemCapability.Utils.Lang */ - export interface MessageEvent extends Event { +export interface MessageEvent extends Event { /** * Data transferred when an exception occurs. * @since 7 @@ -134,8 +134,10 @@ export interface PostMessageOptions { } /** - * Implements evemt listening. + * Implements event listening. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventListener * @syscap SystemCapability.Utils.Lang */ export interface EventListener { @@ -143,11 +145,31 @@ export interface EventListener { * Specifies the callback to invoke. * @param evt Event class for the callback to invoke. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventListener.(event: Event): void | Promise * @syscap SystemCapability.Utils.Lang */ (evt: Event): void | Promise; } +/** + * Implements event listening. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + export interface WorkerEventListener { + /** + * Specifies the callback function to be invoked. + * @param event Event class for the callback to invoke. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + (event: Event): void | Promise; +} + /** * Type of message, only "message" and "messageerror". * @since 7 @@ -158,14 +180,18 @@ type MessageType = "message" | "messageerror"; /** * Specific event features. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventTarget * @syscap SystemCapability.Utils.Lang */ - export interface EventTarget { +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 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventTarget.addEventListener * @syscap SystemCapability.Utils.Lang */ addEventListener( @@ -177,6 +203,8 @@ type MessageType = "message" | "messageerror"; * Dispatches the event defined for the worker. * @param event Event to dispatch. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventTarget.dispatchEvent * @syscap SystemCapability.Utils.Lang */ dispatchEvent(event: Event): boolean; @@ -186,6 +214,8 @@ type MessageType = "message" | "messageerror"; * @param type Type of the event for which the event listener is removed. * @param callback Callback of the event listener to remove. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventTarget.removeEventListener * @syscap SystemCapability.Utils.Lang */ removeEventListener( @@ -196,6 +226,53 @@ type MessageType = "message" | "messageerror"; /** * Removes all event listeners for the worker. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.WorkerEventTarget.removeAllListener + * @syscap SystemCapability.Utils.Lang + */ + removeAllListener(): void; +} + +/** + * Specific worker event features. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ +export interface WorkerEventTarget { + /** + * 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + addEventListener(type: string, listener: WorkerEventListener): void; + /** + * Handle the event defined for the worker. + * @param event Event to dispatch. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + dispatchEvent(event: Event): boolean; + /** + * Remove an event defined for the worker. + * @param type Type of the event for which the event listener is cancelled. + * @param callback Callback of the event listener to remove. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + removeEventListener(type: string, callback?: WorkerEventListener): void; + /** + * Remove all event listeners for the worker. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 * @syscap SystemCapability.Utils.Lang */ removeAllListener(): void; @@ -204,12 +281,16 @@ type MessageType = "message" | "messageerror"; /** * Specifies the worker thread running environment, which is isolated from the host thread environment. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.GlobalScope * @syscap SystemCapability.Utils.Lang */ declare interface WorkerGlobalScope extends EventTarget { /** * Worker name specified when there is a new worker. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.GlobalScope.name * @syscap SystemCapability.Utils.Lang */ readonly name: string; @@ -220,18 +301,53 @@ declare interface WorkerGlobalScope extends EventTarget { * The event handler is executed in the worker thread. * @param ev Error data. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.GlobalScope.onerror * @syscap SystemCapability.Utils.Lang */ onerror?: (ev: ErrorEvent) => void; readonly self: WorkerGlobalScope & typeof globalThis; } +/** + * The environment Specified in which worker threads run, which is isolated from the host thread environment. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + declare interface GlobalScope extends WorkerEventTarget { + /** + * Name of Worker specified when there is a new worker. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + readonly name: string; + + /** + * The onerror attribute of parentPort specified. + * 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 9 + * @syscap SystemCapability.Utils.Lang + */ + onerror?: (ev: ErrorEvent) => void; + /** + * Specify the type attribute for self. + * @param self type is read-only. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + readonly self: GlobalScope & typeof globalThis; +} + /** * Specifies the worker thread running environment, which is isolated from the host thread environment * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorkerGlobalScope * @syscap SystemCapability.Utils.Lang */ - export interface DedicatedWorkerGlobalScope extends WorkerGlobalScope { +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 @@ -239,6 +355,8 @@ declare interface WorkerGlobalScope extends EventTarget { * The event handler is executed in the worker thread. * @param ev Message received. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorkerGlobalScope.onmessage * @syscap SystemCapability.Utils.Lang */ onmessage?: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => void; @@ -249,6 +367,8 @@ declare interface WorkerGlobalScope extends EventTarget { * The event handler is executed in the worker thread. * @param ev Error data. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorkerGlobalScope.onmessageerror * @syscap SystemCapability.Utils.Lang */ onmessageerror?: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => void; @@ -256,6 +376,8 @@ declare interface WorkerGlobalScope extends EventTarget { /** * Close the worker thread to stop the worker from receiving messages * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorkerGlobalScope.close * @syscap SystemCapability.Utils.Lang */ close(): void; @@ -266,6 +388,7 @@ declare interface WorkerGlobalScope extends EventTarget { * @param transfer array cannot contain null. * @since 7 * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorkerGlobalScope.postMessage * @syscap SystemCapability.Utils.Lang */ postMessage(messageObject: Object, transfer: Transferable[]): void; @@ -281,18 +404,253 @@ declare interface WorkerGlobalScope extends EventTarget { postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; } +/** + * Specifies the thread-worker running environment, which is isolated from the host-thread environment + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ +export interface ThreadWorkerGlobalScope extends GlobalScope { + /** + * 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + onmessage?: (this: ThreadWorkerGlobalScope, 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + onmessageerror?: (this: ThreadWorkerGlobalScope, ev: MessageEvent) => void; + + /** + * Close the worker thread to stop the worker from receiving messages + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + close(): void; + + /** + * Send a message to host thread from the worker + * @param messageObject Data to be sent to the worker + * @param transfer array cannot contain null. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200006 - Serializing an uncaught exception failed. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + postMessage(messageObject: Object, transfer: ArrayBuffer[]): void; + + /** + * Send a message to be host thread from the worker + * @param messageObject Data to be sent to the worker + * @param options Option can be set for postmessage. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200006 - Serializing an uncaught exception failed. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + postMessage(messageObject: Object, options?: PostMessageOptions): void; +} + /** * JS cross-thread communication tool * @since 7 * @syscap SystemCapability.Utils.Lang */ declare namespace worker { + /** + * The ThreadWorker class contains all Worker functions. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + class ThreadWorker implements WorkerEventTarget { + /** + * 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 + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200003 - Worker initialization failure. + * @throws {BusinessError} 10200007 - The worker file patch is invalid path. + * @since 9 + * @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 + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200006 - Serializing an uncaught exception failed. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + postMessage(message: Object, transfer: ArrayBuffer[]): 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 + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200006 - Serializing an uncaught exception failed. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + on(type: string, listener: WorkerEventListener): 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 + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + once(type: string, listener: WorkerEventListener): 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + off(type: string, listener?: WorkerEventListener): void; + /** + * Terminates the worker thread to stop the worker from receiving messages + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + terminate(): void; + /** + * 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. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @throws {BusinessError} 10200005 - The invoked API is not supported in workers. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + addEventListener(type: string, listener: WorkerEventListener): void; + /** + * Handle the event defined for the worker. + * @param event Event to dispatch. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + dispatchEvent(event: Event): boolean; + /** + * Remove an event defined for the worker. + * @param type Type of the event for which the event listener is cancelled. + * @param callback Callback of the event listener to remove. + * @throws {BusinessError} 401 - if the input parameters are invalid. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + removeEventListener(type: string, callback?: WorkerEventListener): void; + /** + * Remove all event listeners for the worker. + * @throws {BusinessError} 10200004 - Worker instance is not running. + * @since 9 + * @syscap SystemCapability.Utils.Lang + */ + removeAllListener(): void; + } + class Worker implements 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 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.constructor * @syscap SystemCapability.Utils.Lang */ constructor(scriptURL: string, options?: WorkerOptions); @@ -302,6 +660,8 @@ declare namespace worker { * when the worker exits. The handler is executed in the host thread. * @param code Code indicating the worker exit state * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.onexit * @syscap SystemCapability.Utils.Lang */ onexit?: (code: number) => void; @@ -311,6 +671,8 @@ declare namespace worker { * when an exception occurs during worker execution. * The event handler is executed in the host thread. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.onerror * @syscap SystemCapability.Utils.Lang */ onerror?: (err: ErrorEvent) => void; @@ -322,6 +684,8 @@ declare namespace worker { * The event handler is executed in the host thread. * @param event Message received. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.onmessage * @syscap SystemCapability.Utils.Lang */ onmessage?: (event: MessageEvent) => void; @@ -331,6 +695,8 @@ declare namespace worker { * when the worker receives a message that cannot be serialized. * The event handler is executed in the host thread. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.onmessageerror * @syscap SystemCapability.Utils.Lang */ onmessageerror?: (event: MessageEvent) => void; @@ -342,6 +708,8 @@ declare namespace worker { * @param transfer ArrayBuffer instance that can be transferred. * The transferList array cannot contain null. * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.postMessage * @syscap SystemCapability.Utils.Lang */ postMessage(message: Object, transfer: ArrayBuffer[]): void; @@ -352,6 +720,8 @@ declare namespace 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 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.on * @syscap SystemCapability.Utils.Lang */ on(type: string, listener: EventListener): void; @@ -362,6 +732,8 @@ declare namespace 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 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.once * @syscap SystemCapability.Utils.Lang */ once(type: string, listener: EventListener): void; @@ -371,6 +743,8 @@ declare namespace 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 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.off * @syscap SystemCapability.Utils.Lang */ off(type: string, listener?: EventListener): void; @@ -378,11 +752,14 @@ declare namespace worker { /** * Terminates the worker thread to stop the worker from receiving messages * @since 7 + * @deprecated since 9 + * @useinstead ohos.worker.ThreadWorker.terminate * @syscap SystemCapability.Utils.Lang */ terminate(): void; } const parentPort: DedicatedWorkerGlobalScope; -} + const workerPort: ThreadWorkerGlobalScope; +} export default worker; \ No newline at end of file diff --git a/api/@ohos.xml.d.ts b/api/@ohos.xml.d.ts index 6aed19cbd95ee74dc1d6ded3c7b7db2718e9d4d5..49916703c67d0e1acd46ef7f612628b07df34c59 100644 --- a/api/@ohos.xml.d.ts +++ b/api/@ohos.xml.d.ts @@ -21,6 +21,13 @@ * @permission N/A */ declare namespace xml { + + /** + * The XmlSerializer interface is used to generate an xml file. + * @name XmlSerializer + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ class XmlSerializer { /** * A parameterized constructor used to create a new XmlSerializer instance. @@ -28,6 +35,7 @@ declare namespace xml { * The input parameter is an Arrarybuff. * The input parameter is a DataView. * The input parameter is an encoding format of string type. + * @throws {BusinessError} 401 - if the input parameters are invalid. */ constructor(buffer: ArrayBuffer | DataView, encoding?: string); @@ -37,6 +45,7 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @param name Key name of the attribute. * @param value Values of attribute. + * @throws {BusinessError} 401 - if the input parameters are invalid. */ setAttributes(name: string, value: string): void; @@ -46,6 +55,7 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @param name Key name of the attribute. * @param value Values of element. + * @throws {BusinessError} 401 - The type of name must be string. */ addEmptyElement(name: string): void; @@ -60,7 +70,8 @@ declare namespace xml { * Writes a elemnet start tag with the given name. * @since 8 * @syscap SystemCapability.Utils.Lang - * @param name name of the element. + * @param name Name of the element. + * @throws {BusinessError} 401 - The type of name must be string. */ startElement(name: string): void; @@ -77,6 +88,7 @@ declare namespace xml { * @syscap SystemCapability.Utils.Lang * @param prefix Values name of the prefix. * @param namespace Values of namespace. + * @throws {BusinessError} 401 - if the input parameters are invalid. */ setNamespace(prefix: string, namespace: string): void; @@ -85,6 +97,7 @@ declare namespace xml { * @since 8 * @syscap SystemCapability.Utils.Lang * @param text Values of comment. + * @throws {BusinessError} 401 - The type of text must be string. */ setComment(text: string): void; @@ -93,6 +106,7 @@ declare namespace xml { * @since 8 * @syscap SystemCapability.Utils.Lang * @param text Values of CDATA. + * @throws {BusinessError} 401 - The type of text must be string. */ setCDATA(text: string): void; @@ -101,6 +115,7 @@ declare namespace xml { * @since 8 * @syscap SystemCapability.Utils.Lang * @param text Values of text. + * @throws {BusinessError} 401 - The type of text must be string. */ setText(text: string): void; @@ -109,6 +124,7 @@ declare namespace xml { * @since 8 * @syscap SystemCapability.Utils.Lang * @param text Values of docType. + * @throws {BusinessError} 401 - The type of text must be string. */ setDocType(text: string): void; } @@ -175,7 +191,7 @@ declare namespace xml { */ ENTITY_REFERENCE, /** - * a whitespace. + * A whitespace. * @since 8 * @syscap SystemCapability.Utils.Lang */ @@ -246,7 +262,7 @@ declare namespace xml { getAttributeCount(): number; } - /** parse options for XmlPullParser. */ + /** Parse options for XmlPullParser. */ interface ParseOptions { /** @@ -264,7 +280,7 @@ declare namespace xml { ignoreNameSpace?: boolean; /** - * tag value callback function. + * Tag value callback function. * @since 8 * @syscap SystemCapability.Utils.Lang * @param name The current tag name. @@ -274,7 +290,7 @@ declare namespace xml { tagValueCallbackFunction?: (name: string, value: string) => boolean; /** - * attribute value callback function. + * Attribute value callback function. * @since 8 * @syscap SystemCapability.Utils.Lang * @param name The current attribute name. @@ -284,7 +300,7 @@ declare namespace xml { attributeValueCallbackFunction?: (name: string, value: string) => boolean; /** - * token value callback function. + * Token value callback function. * @since 8 * @syscap SystemCapability.Utils.Lang * @param eventType The current token eventtype. @@ -294,10 +310,17 @@ declare namespace xml { tokenValueCallbackFunction?: (eventType: EventType, value: ParseInfo) => boolean; } + /** + * The XmlPullParser interface is used to parse the existing xml file. + * @name XmlPullParser + * @since 8 + * @syscap SystemCapability.Utils.Lang + */ class XmlPullParser { /** - * A constructor used to create a new XmlPullParser instance. - */ + * A constructor used to create a new XmlPullParser instance. + * @throws {BusinessError} 401 - if the input parameters are invalid. + */ constructor(buffer: ArrayBuffer | DataView, encoding?: string); /** @@ -305,6 +328,7 @@ declare namespace xml { * @since 8 * @syscap SystemCapability.Utils.Lang * @param option parse options for XmlPullParser, the interface including two Boolean variables and three callback functions. + * @throws {BusinessError} 401 - The type of option must be ParseOptions. */ parse(option: ParseOptions): void; } diff --git a/api/@system.battery.d.ts b/api/@system.battery.d.ts index 9aee8309bf61ee9c26b8e9a743cc3b1a3bd9a745..246a61658bf6dd9a4496f56d90a7863e4501fef0 100755 --- a/api/@system.battery.d.ts +++ b/api/@system.battery.d.ts @@ -16,20 +16,20 @@ /** * @syscap SystemCapability.PowerManager.BatteryManager.Core * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ export interface BatteryResponse { /** * Whether the battery is being charged. * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ charging: boolean; /** * Current battery level, which ranges from 0.00 to 1.00. * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ level: number; } @@ -37,27 +37,27 @@ /** * @syscap SystemCapability.PowerManager.BatteryManager.Core * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ export interface GetStatusOptions { /** * Called when the current charging state and battery level are obtained. * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ success?: (data: BatteryResponse) => void; /** * Called when the current charging state and battery level fail to be obtained. * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ fail?: (data: string, code: number) => void; /** * Called when the execution is completed. * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ complete?: () => void; } @@ -65,14 +65,14 @@ export interface GetStatusOptions { /** * @syscap SystemCapability.PowerManager.BatteryManager.Core * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ export default class Battery { /** * Obtains the current charging state and battery level. * @param options Options. * @since 3 - * @deprecated since 9 + * @deprecated since 6 */ static getStatus(options?: GetStatusOptions): void; } \ No newline at end of file diff --git a/api/@system.brightness.d.ts b/api/@system.brightness.d.ts index d5c656768d75df400570881bef66a68bb22bcda8..806775ade8de6f1909f9ac2cede761534bdff85f 100755 --- a/api/@system.brightness.d.ts +++ b/api/@system.brightness.d.ts @@ -16,13 +16,13 @@ /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface BrightnessResponse { /** - * Screen brightness, which ranges from 1 to 100. + * Screen brightness, which ranges from 1 to 255. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ value: number; } @@ -30,27 +30,27 @@ export interface BrightnessResponse { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface GetBrightnessOptions { /** * Called when the current screen brightness is obtained. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ success?: (data: BrightnessResponse) => void; /** * Called when the current screen brightness fails to be obtained. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ fail?: (data: string, code: number) => void; /** * Called when the execution is completed. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ complete?: () => void; } @@ -58,38 +58,38 @@ export interface GetBrightnessOptions { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface SetBrightnessOptions { /** - * Screen brightness. The value is an integer ranging from 1 to 100. + * Screen brightness. The value is an integer ranging from 1 to 255. * 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 is greater than 255, value 255 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 - * @deprecated since 9 + * @deprecated since 7 */ value: number; /** * Called when the setting is successful. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ success?: () => void; /** * Called when the setting fails. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ fail?: (data: string, code: number) => void; /** * Called when the execution is completed. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ complete?: () => void } @@ -97,7 +97,7 @@ export interface SetBrightnessOptions { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface BrightnessModeResponse { /** @@ -105,7 +105,7 @@ export interface BrightnessModeResponse { * 0: The screen brightness is manually adjusted. * 1: The screen brightness is automatically adjusted. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ mode: number; } @@ -113,27 +113,27 @@ export interface BrightnessModeResponse { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface GetBrightnessModeOptions { /** * Called when the screen brightness adjustment mode is obtained. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ success?: (data: BrightnessModeResponse) => void; /** * Called when the screen brightness adjustment mode fails to be obtained. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ fail?: (data: string, code: number) => void; /** * Called when the execution is completed. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ complete?: () => void; } @@ -141,7 +141,7 @@ export interface GetBrightnessModeOptions { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface SetBrightnessModeOptions { /** @@ -149,28 +149,28 @@ export interface SetBrightnessModeOptions { * 0: The screen brightness is manually adjusted. * 1: The screen brightness is automatically adjusted. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ mode: number; /** * Called when the setting is successful. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ success?: () => void; /** * Called when the setting fails. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ fail?: (data: string, code: number) => void; /** * Called when the execution is completed. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ complete?: () => void } @@ -178,34 +178,34 @@ export interface SetBrightnessModeOptions { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export interface SetKeepScreenOnOptions { /** * Whether to always keep the screen on. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ keepScreenOn: boolean; /** * Called when the setting is successful. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ success?: () => void; /** * Called when the setting fails. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ fail?: (data: string, code: number) => void; /** * Called when the execution is completed. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ complete?: () => void } @@ -213,14 +213,14 @@ export interface SetKeepScreenOnOptions { /** * @syscap SystemCapability.PowerManager.DisplayPowerManager * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ export default class Brightness { /** * Obtains the current screen brightness. * @param options Options. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ static getValue(options?: GetBrightnessOptions): void; @@ -228,7 +228,7 @@ export default class Brightness { * Sets the screen brightness. * @param options Options. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ static setValue(options?: SetBrightnessOptions): void; @@ -236,7 +236,7 @@ export default class Brightness { * Obtains the screen brightness adjustment mode. * @param options Options. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ static getMode(options?: GetBrightnessModeOptions): void; @@ -244,7 +244,7 @@ export default class Brightness { * Sets the screen brightness adjustment mode. * @param options Options. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ static setMode(options?: SetBrightnessModeOptions): void; @@ -252,7 +252,7 @@ export default class Brightness { * Sets whether to always keey the screen on. * @param options Options. * @since 3 - * @deprecated since 9 + * @deprecated since 7 */ static setKeepScreenOn(options?: SetKeepScreenOnOptions): void; } \ No newline at end of file diff --git a/api/@system.package.d.ts b/api/@system.package.d.ts index 7a667d63cc945dcedf9a9d11311e6145ae4daaca..548e4ec621652010e83c94b8fe8f3b89f447ef64 100644 --- a/api/@system.package.d.ts +++ b/api/@system.package.d.ts @@ -16,6 +16,7 @@ /** * @syscap SystemCapability.BundleManager.BundleFramework * @since 3 + * @deprecated since 9 */ export interface CheckPackageHasInstalledResponse { /** @@ -29,6 +30,7 @@ export interface CheckPackageHasInstalledResponse { /** * @syscap SystemCapability.BundleManager.BundleFramework * @since 3 + * @deprecated since 9 */ export interface CheckPackageHasInstalledOptions { /** @@ -64,12 +66,14 @@ export interface CheckPackageHasInstalledOptions { * @syscap SystemCapability.BundleManager.BundleFramework * @since 3 * @import package from '@system.package'; + * @deprecated since 9 */ export default class Package { /** * Checks whethers an application exists, or whether a native application has been installed. * @param options Options * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 */ static hasInstalled(options: CheckPackageHasInstalledOptions): void; } \ No newline at end of file diff --git a/api/@system.prompt.d.ts b/api/@system.prompt.d.ts index c2b4c100add4b46b9bd59fa90820312544045ea1..78025362a649a5f6113d53eff115c11cb0dd72c7 100644 --- a/api/@system.prompt.d.ts +++ b/api/@system.prompt.d.ts @@ -17,6 +17,8 @@ * Defines the options of ShowToast. * @syscap SystemCapability.ArkUI.ArkUI.Full * @since 3 + * @deprecated since 8 + * @useinstead ohos.prompt */ export interface ShowToastOptions { /** diff --git a/api/application/AbilityContext.d.ts b/api/application/AbilityContext.d.ts index c42a2a2981bb67cd740d475160dd03b0764c3191..64c9ea8ba9971f94612865ebb9d6b176aa1c2379 100755 --- a/api/application/AbilityContext.d.ts +++ b/api/application/AbilityContext.d.ts @@ -15,207 +15,370 @@ /// -import { AbilityInfo } from "../bundle/abilityInfo"; +import { AbilityInfo } from "../bundleManager/abilityInfo"; import { AbilityResult } from "../ability/abilityResult"; import { AsyncCallback } from "../basic"; import { ConnectOptions } from "../ability/connectOptions"; -import { HapModuleInfo } from "../bundle/hapModuleInfo"; +import { HapModuleInfo } from "../bundleManager/hapModuleInfo"; import Context from "./Context"; import Want from "../@ohos.application.Want"; -import StartOptions from "../@ohos.application.StartOptions"; +import StartOptions from "../@ohos.app.ability.StartOptions"; import PermissionRequestResult from "./PermissionRequestResult"; -import { Configuration } from '../@ohos.application.Configuration'; -import Caller from '../@ohos.application.Ability'; +import { Configuration } from '../@ohos.app.ability.Configuration'; +import { Caller } from '../@ohos.app.ability.UIAbility'; import { LocalStorage } from 'StateManagement'; import image from '../@ohos.multimedia.image'; /** * The context of an ability. It allows access to ability-specific resources. - * - * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @permission N/A - * @StageModelOnly + * @stagemodelonly + * @since 9 */ export default class AbilityContext extends Context { /** * Indicates configuration information about an ability. - * - * @since 9 + * @type { AbilityInfo } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ abilityInfo: AbilityInfo; /** - * Indicates configuration information about an module. - * - * @since 9 + * Indicates configuration information about the module. + * @type { HapModuleInfo } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ currentHapModuleInfo: HapModuleInfo; /** * Indicates configuration information. - * - * @since 9 + * @type { Configuration } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ config: Configuration; /** * Starts a new ability. - * - * @since 9 + * @param want { Want } - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the ability to start. - * @param options Indicates the start options. - * @return - - * @StageModelOnly + * @stagemodelonly + * @since 9 */ startAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts a new ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ startAbility(want: Want, options?: StartOptions): Promise; /** * Get the caller object of the startup capability - * - * @since 9 + * @param { Want } want - Indicates the ability to start. + * @returns { Promise } Returns the Caller interface. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @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 + * @systemapi + * @stagemodelonly + * @since 9 */ startAbilityByCall(want: Want): Promise; /** * Starts a new ability with account. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @param accountId Indicates the account to start. - * @param options Indicates the start options. - * @systemapi hide for inner use. - * @return - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS - * @StageModelOnly + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; /** * Starts an ability and returns the execution result when the ability is destroyed. - * - * @since 9 + * @param { Want } want - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the ability to start. - * @param options Indicates the start options. - * @return Returns the {@link AbilityResult}. - * @StageModelOnly + * @stagemodelonly + * @since 9 */ startAbilityForResult(want: Want, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } Returns the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ startAbilityForResult(want: Want, options?: StartOptions): Promise; /** * Starts an ability and returns the execution result when the ability is destroyed with account. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @param accountId Indicates the account to start. - * @param options Indicates the start options. - * @systemapi hide for inner use. - * @return Returns the {@link AbilityResult}. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS - * @StageModelOnly + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } Returns the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; /** * Starts a new service extension ability. - * - * @since 9 + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ startServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startServiceExtensionAbility(want: Want): Promise; /** * Starts a new service extension ability with account. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @param accountId Indicates the account to start. - * @systemapi hide for inner use. - * @return - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. - * @StageModelOnly + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; /** * Stops a service within the same application. - * - * @since 9 + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ stopServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Stops a service within the same application. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ stopServiceExtensionAbility(want: Want): Promise; /** * Stops a service within the same application with account. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @param accountId Indicates the accountId to start. - * @systemapi hide for inner use. - * @return - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. - * @StageModelOnly + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Stops a service within the same application with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; /** * Destroys this Page ability. - * - * @since 9 + * @param { AsyncCallback } callback - The callback of terminateSelf. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @return - - * @StageModelOnly + * @stagemodelonly + * @since 9 */ terminateSelf(callback: AsyncCallback): void; + + /** + * Destroys this Page ability. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ 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 + * @param { AbilityResult } parameter - Indicates the result to return. + * @param { AsyncCallback } callback - The callback of terminateSelfWithResult. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param parameter Indicates the result to return. - * @return - - * @StageModelOnly + * @stagemodelonly + * @since 9 */ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback): void; + + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * @param { AbilityResult } parameter - Indicates the result to return. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ terminateSelfWithResult(parameter: AbilityResult): Promise; /** @@ -228,6 +391,8 @@ export default class AbilityContext extends Context { * @systemapi Hide this for inner system use. * @return Returns the number code of the ability connected * @StageModelOnly + * @deprecated since 9 + * @useinstead connectServiceExtensionAbility */ connectAbility(want: Want, options: ConnectOptions): number; @@ -243,6 +408,8 @@ export default class AbilityContext extends Context { * @return Returns the number code of the ability connected * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @StageModelOnly + * @deprecated since 9 + * @useinstead connectServiceExtensionAbilityWithAccount */ connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; @@ -254,63 +421,148 @@ export default class AbilityContext extends Context { * @param connection The number code of the ability connected * @systemapi Hide this for inner system use. * @StageModelOnly + * @deprecated since 9 + * @useinstead disconnectServiceExtensionAbility */ disconnectAbility(connection: number, callback:AsyncCallback): void; disconnectAbility(connection: number): Promise; + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @param { Want } want - The element name of the service ability + * @param { ConnectOptions } options - The remote object instance + * @returns { number } Returns the number code of the ability connected + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - The element name of the service ability + * @param { number } accountId - The account to connect + * @param { ConnectOptions } options - The remote object instance + * @returns { number } Returns the number code of the ability connected + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * The callback interface was connect successfully. + * @param { number } connection - The number code of the ability connected + * @param { AsyncCallback } callback - The callback of disconnectAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback): void; + + /** + * The callback interface was connect successfully. + * @param { number } connection - The number code of the ability connected + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number): Promise; + /** * Set mission label of current ability. - * + * @param { string } label - The label of ability that showed in recent missions. + * @param { AsyncCallback } callback - The callback of setMissionLabel. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly * @since 9 + */ + setMissionLabel(label: string, callback: AsyncCallback): void; + + /** + * Set mission label of current ability. + * @param { string } label - The label of ability that showed in recent missions. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param label The label of ability that showed in recent missions. - * @StageModelOnly + * @stagemodelonly + * @since 9 */ - setMissionLabel(label: string, callback:AsyncCallback): void; - setMissionLabel(label: string): Promise; + setMissionLabel(label: string): Promise; /** * Set mission icon of current ability. - * + * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. + * @param { AsyncCallback } callback - The callback of setMissionIcon. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly * @since 9 + */ + setMissionIcon(icon: image.PixelMap, callback: AsyncCallback): void; + + /** + * Set mission icon of current ability. + * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param icon The icon of ability that showed in recent missions. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ - setMissionIcon(icon: image.PixelMap, callback:AsyncCallback): void; - setMissionIcon(icon: image.PixelMap): Promise; + setMissionIcon(icon: image.PixelMap): Promise; - /** + /** * Requests certain permissions from the system. - * + * @param { Array } permissions - Indicates the list of permissions to be requested. This parameter + * cannot be null or empty. + * @param { AsyncCallback } requestCallback - The callback is used to return the permission + * request result. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly * @since 9 + */ + requestPermissionsFromUser(permissions: Array, requestCallback: AsyncCallback): void; + + /** + * Requests certain permissions from the system. + * @param { Array } permissions - Indicates the list of permissions to be requested. This parameter + * cannot be null or empty. + * @returns { Promise } Returns the permission request result. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @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 + * @stagemodelonly + * @since 9 */ - requestPermissionsFromUser(permissions: Array, requestCallback: AsyncCallback) : void; - requestPermissionsFromUser(permissions: Array) : Promise; + requestPermissionsFromUser(permissions: Array): Promise; /** * Restore window stage data in ability continuation - * - * @since 9 + * @param { LocalStorage } localStorage - the storage data used to restore window stage + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param LocalStorage the storage data used to restore window stage - * @StageModelOnly + * @stagemodelonly + * @since 9 */ - restoreWindowStage(localStorage: LocalStorage) : void; + restoreWindowStage(localStorage: LocalStorage): void; /** * check to see ability is in terminating state. - * - * @since 9 + * @returns { boolean } Returns true when ability is in terminating state, else returns false. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @return Returns true when ability is in terminating state, else returns false. - * @StageModelOnly + * @stagemodelonly + * @since 9 */ isTerminating(): boolean; } diff --git a/api/application/AbilityRunningInfo.d.ts b/api/application/AbilityRunningInfo.d.ts index 864465c87b22972ca735b6293fb3b5ad2e39de80..63b82692d4882b7fb2ee1e533577287609fff864 100644 --- a/api/application/AbilityRunningInfo.d.ts +++ b/api/application/AbilityRunningInfo.d.ts @@ -14,7 +14,7 @@ */ import { ElementName } from '../bundle/elementName'; -import abilityManager from '../@ohos.application.abilityManager'; +import abilityManager from '../@ohos.app.ability.abilityManager'; /** * The class of an ability running information. diff --git a/api/application/AbilityStageContext.d.ts b/api/application/AbilityStageContext.d.ts index 4b2777b37d1f0f7a7441e4e0c7661829f3fce56b..d5feff64cf43cbc4652446562f0b2a6b6058dfd6 100644 --- a/api/application/AbilityStageContext.d.ts +++ b/api/application/AbilityStageContext.d.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { HapModuleInfo } from "../bundle/hapModuleInfo"; -import { Configuration } from '../@ohos.application.Configuration'; +import { HapModuleInfo } from "../bundleManager/hapModuleInfo"; +import { Configuration } from '../@ohos.app.ability.Configuration'; import Context from "./Context"; /** diff --git a/api/application/AccessibilityExtensionContext.d.ts b/api/application/AccessibilityExtensionContext.d.ts index 76ee1b0e0bc988890bed83dc459bcc4a5ddd059e..d3c38cddded2ee8d53cf57cc0e92b4948f1dbc90 100644 --- a/api/application/AccessibilityExtensionContext.d.ts +++ b/api/application/AccessibilityExtensionContext.d.ts @@ -28,6 +28,7 @@ export default class AccessibilityExtensionContext extends ExtensionContext { /** * Set the name of the bundle name that is interested in sending the event. * @param targetNames + * @throws { BusinessError } 401 - Input parameter error. */ setTargetBundleName(targetNames: Array): Promise; setTargetBundleName(targetNames: Array, callback: AsyncCallback): void; @@ -35,6 +36,7 @@ export default class AccessibilityExtensionContext extends ExtensionContext { /** * Get focus element. * @param isAccessibilityFocus Indicates whether the acquired element has an accessibility focus. + * @throws { BusinessError } 9300003 - Do not have accessibility right for this operation. */ getFocusElement(isAccessibilityFocus?: boolean): Promise; getFocusElement(callback: AsyncCallback): void; @@ -43,6 +45,7 @@ export default class AccessibilityExtensionContext extends ExtensionContext { /** * Get window root element. * @param windowId Indicates the window ID. + * @throws { BusinessError } 9300003 - Do not have accessibility right for this operation. */ getWindowRootElement(windowId?: number): Promise; getWindowRootElement(callback: AsyncCallback): void; @@ -51,6 +54,7 @@ export default class AccessibilityExtensionContext extends ExtensionContext { /** * Get window list. * @param displayId Indicates the display ID. + * @throws { BusinessError } 9300003 - Do not have accessibility right for this operation. */ getWindows(displayId?: number): Promise>; getWindows(callback: AsyncCallback>): void; @@ -59,6 +63,8 @@ export default class AccessibilityExtensionContext extends ExtensionContext { /** * Inject gesture path events. * @param gesturePath Indicates the gesture path. + * @throws { BusinessError } 401 - Input parameter error. + * @throws { BusinessError } 9300003 - Do not have accessibility right for this operation. */ injectGesture(gesturePath: GesturePath): Promise; injectGesture(gesturePath: GesturePath, callback: AsyncCallback): void; @@ -81,6 +87,8 @@ declare interface AccessibilityElement { /** * Get the value of an attribute. * @param attributeName Indicates the attribute name. + * @throws { BusinessError } 401 - Input parameter error. + * @throws { BusinessError } 9300004 - This property does not exist. */ attributeValue(attributeName: T): Promise; attributeValue(attributeName: T, @@ -96,15 +104,18 @@ declare interface AccessibilityElement { * Perform the specified action. * @param actionName Indicates the action name. * @param parameters Indicates the parameters needed to execute the action. + * @throws { BusinessError } 401 - Input parameter error. + * @throws { BusinessError } 9300005 - This action is not supported. */ - performAction(actionName: string, parameters?: object): Promise; - performAction(actionName: string, callback: AsyncCallback): void; - performAction(actionName: string, parameters: object, callback: AsyncCallback): void; + 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. + * @throws { BusinessError } 401 - Input parameter error. */ findElement(type: 'content', condition: string): Promise>; findElement(type: 'content', condition: string, callback: AsyncCallback>): void @@ -113,6 +124,7 @@ declare interface AccessibilityElement { * 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. + * @throws { BusinessError } 401 - Input parameter error. */ findElement(type: 'focusType', condition: FocusType): Promise; findElement(type: 'focusType', condition: FocusType, callback: AsyncCallback): void @@ -121,6 +133,7 @@ declare interface AccessibilityElement { * 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. + * @throws { BusinessError } 401 - Input parameter error. */ findElement(type: 'focusDirection', condition: FocusDirection): Promise; findElement(type: 'focusDirection', condition: FocusDirection, callback: AsyncCallback): void diff --git a/api/application/ApplicationContext.d.ts b/api/application/ApplicationContext.d.ts index 2f605c61cf00e4bfa78422ab766a12527bcc5db8..8fc1e3b46f25faebf87a887c0f0345e78b9680bb 100755 --- a/api/application/ApplicationContext.d.ts +++ b/api/application/ApplicationContext.d.ts @@ -15,16 +15,15 @@ import { AsyncCallback } from "../basic"; import Context from "./Context"; -import AbilityLifecycleCallback from "../@ohos.application.AbilityLifecycleCallback"; -import EnvironmentCallback from "../@ohos.application.EnvironmentCallback"; +import AbilityLifecycleCallback from "../@ohos.app.ability.AbilityLifecycleCallback"; +import EnvironmentCallback from "../@ohos.app.ability.EnvironmentCallback"; +import { ProcessRunningInformation } from "./ProcessRunningInformation"; /** * The context of an application. It allows access to application-specific resources. - * - * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @permission N/A - * @StageModelOnly + * @stagemodelonly + * @since 9 */ export default class ApplicationContext extends Context { /** @@ -35,6 +34,8 @@ export default class ApplicationContext extends Context { * @param callback The ability lifecycle callback. * @return Returns the number code of the callback. * @StageModelOnly + * @deprecated since 9 + * @useinstead on */ registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): number; @@ -46,6 +47,8 @@ export default class ApplicationContext extends Context { * @param callbackId Indicates the number code of the callback. * @return - * @StageModelOnly + * @deprecated since 9 + * @useinstead off */ unregisterAbilityLifecycleCallback(callbackId: number, callback: AsyncCallback): void; unregisterAbilityLifecycleCallback(callbackId: number): Promise; @@ -58,6 +61,8 @@ export default class ApplicationContext extends Context { * @param callback The environment callback. * @return Returns the number code of the callback. * @StageModelOnly + * @deprecated since 9 + * @useinstead on */ registerEnvironmentCallback(callback: EnvironmentCallback): number; @@ -69,7 +74,121 @@ export default class ApplicationContext extends Context { * @param callbackId Indicates the number code of the callback. * @return - * @StageModelOnly + * @deprecated since 9 + * @useinstead off */ unregisterEnvironmentCallback(callbackId: number, callback: AsyncCallback): void; unregisterEnvironmentCallback(callbackId: number): Promise; + + /** + * Register ability lifecycle callback. + * @param { string } type - abilityLifecycle. + * @param { AbilityLifecycleCallback } callback - The ability lifecycle callback. + * @returns { number } Returns the number code of the callback. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + on(type: "abilityLifecycle", callback: AbilityLifecycleCallback): number; + + /** + * Unregister ability lifecycle callback. + * @param { string } type - abilityLifecycle. + * @param { number } callbackId - Indicates the number code of the callback. + * @param { AsyncCallback } callback - The callback of off. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + off(type: "abilityLifecycle", callbackId: number, callback: AsyncCallback): void; + + /** + * Unregister ability lifecycle callback. + * @param { string } type - abilityLifecycle. + * @param { number } callbackId - Indicates the number code of the callback. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + off(type: "abilityLifecycle", callbackId: number): Promise; + + /** + * Register environment callback. + * @param { string } type - environment. + * @param { EnvironmentCallback } callback - The environment callback. + * @returns { number } Returns the number code of the callback. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + on(type: "environment", callback: EnvironmentCallback): number; + + /** + * Unregister environment callback. + * @param { string } type - environment. + * @param { number } callbackId - Indicates the number code of the callback. + * @param { AsyncCallback } callback - The callback of unregisterEnvironmentCallback. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + off(type: "environment", callbackId: number, callback: AsyncCallback): void; + + /** + * Unregister environment callback. + * @param { string } type - environment. + * @param { number } callbackId - Indicates the number code of the callback. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + off(type: "environment", callbackId: number): Promise; + + /** + * Get information about running processes + * @returns { Promise> } Returns the array of {@link ProcessRunningInformation}. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + getProcessRunningInformation(): Promise>; + + /** + * Get information about running processes + * @param { AsyncCallback> } callback - The callback is used to return the array of {@link ProcessRunningInformation}. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + getProcessRunningInformation(callback: AsyncCallback>): void; + + /** + * Kill processes by self + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + killProcessesBySelf(): Promise; + + /** + * Kill processes by self + * @param { AsyncCallback } callback - The callback of killProcessesBySelf. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + killProcessesBySelf(callback: AsyncCallback); } diff --git a/api/application/Context.d.ts b/api/application/Context.d.ts index 26c6eadcadde30f17ddc7dac2d1dcd787881ad7b..67b1316ac0300af915458bdf05d1cb37a1c485ab 100755 --- a/api/application/Context.d.ts +++ b/api/application/Context.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { ApplicationInfo } from "../bundle/applicationInfo"; +import { ApplicationInfo } from "../bundleManager/applicationInfo"; import resmgr from "../@ohos.resourceManager"; import BaseContext from "./BaseContext"; import EventHub from "./EventHub"; @@ -22,166 +22,163 @@ 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 + * @stagemodelonly + * @since 9 */ export default class Context extends BaseContext { /** * Indicates the capability of accessing application resources. - * - * @since 9 + * @type { resmgr.ResourceManager } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ resourceManager: resmgr.ResourceManager; /** * Indicates configuration information about an application. - * - * @since 9 + * @type { ApplicationInfo } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ applicationInfo: ApplicationInfo; /** * Indicates app cache dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ cacheDir: string; /** * Indicates app temp dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ tempDir: string; /** * Indicates app files dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ - filesDir : string; + filesDir: string; /** * Indicates app database dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ - databaseDir : string; + databaseDir: string; /** * Indicates app preferences dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ - preferencesDir : string; + preferencesDir: string; /** * Indicates app bundle code dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ - bundleCodeDir : string; + bundleCodeDir: string; /** * Indicates app distributed files dir. - * - * @since 9 + * @type { string } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ distributedFilesDir: string; /** * Indicates event hub. - * - * @since 9 + * @type { EventHub } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ eventHub: EventHub; /** * Indicates file area. - * - * @since 9 + * @type { AreaMode } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ area: AreaMode; /** * Create a bundle context - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @systemapi hide for inner use. - * @param bundleName Indicates the bundle name. - * @return application context * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED - * @StageModelOnly + * @param { string } bundleName - Indicates the bundle name. + * @returns { Context } Returns the application context. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ createBundleContext(bundleName: string): Context; /** * Create a module context - * - * @since 9 + * @param { string } moduleName - Indicates the module name. + * @returns { Context } Returns the application context. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param moduleName Indicates the module name. - * @return application context - * @StageModelOnly + * @stagemodelonly + * @since 9 */ createModuleContext(moduleName: string): Context; /** * Create a module context - * - * @since 9 + * @param { string } bundleName - Indicates the bundle name. + * @param { string } moduleName - Indicates the module name. + * @returns { Context } Returns the application context. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @systemapi hide for inner use. - * @param bundleName Indicates the bundle name. - * @param moduleName Indicates the module name. - * @return application context - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ createModuleContext(bundleName: string, moduleName: string): Context; /** * Get application context - * - * @since 9 + * @returns { ApplicationContext } Returns the application context. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @return application context - * @StageModelOnly + * @stagemodelonly + * @since 9 */ getApplicationContext(): ApplicationContext; } /** - * File area mode - * - * @since 9 + * Enum for the file area mode + * @enum { number } * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @StageModelOnly + * @stagemodelonly + * @since 9 */ export enum AreaMode { /** diff --git a/api/application/ContinueDeviceInfo.d.ts b/api/application/ContinueDeviceInfo.d.ts index d6402c3d069e39fdfa74fa898ff9702d38925edf..e557838b04dd89a2412ab64ef8d87c8fb8ff60c4 100644 --- a/api/application/ContinueDeviceInfo.d.ts +++ b/api/application/ContinueDeviceInfo.d.ts @@ -44,10 +44,10 @@ */ missionId: number; /** - * Indicates the extended params. + * Indicates the extended param. * * @syscap SystemCapability.Ability.AbilityRuntime.Mission * @since 9 */ - wantParams: {[key: string]: any}; + wantParam: {[key: string]: any}; } \ No newline at end of file diff --git a/api/application/EventHub.d.ts b/api/application/EventHub.d.ts index 7fe3d203caeeacd2d0139d830ecb382e61b02538..6947fca11f426cfbaff5ac2f66e0e18843c9289f 100644 --- a/api/application/EventHub.d.ts +++ b/api/application/EventHub.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -13,48 +13,45 @@ * limitations under the License. */ +import { BusinessError } from '../basic'; + /** * The event center of a context, support the subscription and publication of events. - * - * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @permission N/A - * @StageModelOnly + * @stagemodelonly + * @since 9 */ export default class EventHub { /** * Subscribe to an event. - * - * @since 9 + * @param { string } event - Indicates the event. + * @param { Function } callback - Indicates the callback. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param event Indicates the event. - * @param callback Indicates the callback. - * @return - - * @StageModelOnly + * @stagemodelonly + * @since 9 */ on(event: string, callback: Function): void /** * Unsubscribe from an event. - * - * @since 9 + * @param { string } event - Indicates the event. + * @param { Function } callback - Indicates the callback. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param event Indicates the event. - * @param callback Indicates the callback. - * @return - - * @StageModelOnly + * @stagemodelonly + * @since 9 */ off(event: string, callback?: Function): void /** * Trigger the event callbacks. - * - * @since 9 + * @param { string } event - Indicates the event. + * @param { Object[] } args - Indicates the callback arguments. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param event Indicates the event. - * @param args Indicates the callback arguments. - * @return - - * @StageModelOnly + * @stagemodelonly + * @since 9 */ emit(event: string, ...args: Object[]): void } \ No newline at end of file diff --git a/api/application/ExtensionContext.d.ts b/api/application/ExtensionContext.d.ts index 3e20d41b8e4306a128b5142a89b509a5067cdcb1..472c4471939624685b80512703f156cf3282a290 100644 --- a/api/application/ExtensionContext.d.ts +++ b/api/application/ExtensionContext.d.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -import { HapModuleInfo } from "../bundle/hapModuleInfo"; -import { Configuration } from '../@ohos.application.Configuration'; +import { HapModuleInfo } from "../bundleManager/hapModuleInfo"; +import { Configuration } from '../@ohos.app.ability.Configuration'; import Context from "./Context"; -import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo"; +import { ExtensionAbilityInfo } from "../bundleManager/extensionAbilityInfo"; /** * The context of an extension. It allows access to extension-specific resources. diff --git a/api/application/ExtensionRunningInfo.d.ts b/api/application/ExtensionRunningInfo.d.ts index 32abe9c2647daf5c7c6f5f7f8ce0ddd4515a4cbc..7a4ef741fa8afba569aed1da0a01adb84f6a9b91 100644 --- a/api/application/ExtensionRunningInfo.d.ts +++ b/api/application/ExtensionRunningInfo.d.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { ElementName } from '../bundle/elementName'; -import bundle from '../@ohos.bundle'; +import { ElementName } from '../bundleManager/elementName'; +import bundle from '../@ohos.bundle.bundleManager'; /** * The class of an extension running information. @@ -74,7 +74,7 @@ export interface ExtensionRunningInfo { clientPackage: Array; /** - * @default Enumerates types of the entension info + * @default Enumerates types of the extension info * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi hide this for inner system use diff --git a/api/application/ServiceExtensionContext.d.ts b/api/application/ServiceExtensionContext.d.ts index dd21ca7d0a1e5c23fa5b7bd77e6e709f5779c922..acc02d4176ba65bd828302dc46c9b3e867254df0 100644 --- a/api/application/ServiceExtensionContext.d.ts +++ b/api/application/ServiceExtensionContext.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * 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 @@ -15,119 +15,223 @@ import { AsyncCallback } from "../basic"; import { ConnectOptions } from "../ability/connectOptions"; -import Caller from '../@ohos.application.Ability'; +import { Caller } from '../@ohos.app.ability.UIAbility'; import ExtensionContext from "./ExtensionContext"; import Want from "../@ohos.application.Want"; -import StartOptions from "../@ohos.application.StartOptions"; +import StartOptions from "../@ohos.app.ability.StartOptions"; /** * The context of service extension. It allows access to * serviceExtension-specific resources. - * - * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @systemapi hide for inner use. - * @permission N/A - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ export default class ServiceExtensionContext extends ExtensionContext { /** * Service extension uses this method to start a specific ability. - * - * @since 9 + * @param { Want } want - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the ability to start. - * @param options Indicates the start options. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ startAbility(want: Want, callback: AsyncCallback): void; + + /** + * Service extension uses this method to start a specific ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Service extension uses this method to start a specific ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbility(want: Want, options?: StartOptions): Promise; /** * Service extension uses this method to start a specific ability with account. - * - * @since 9 + * @param { Want } want - Indicates the ability to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the ability to start. - * @param accountId Indicates the accountId to start. - * @param options Indicates the start options. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Service extension uses this method to start a specific ability with account. + * @param { Want } want - Indicates the ability to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Service extension uses this method to start a specific ability with account. + * @param { Want } want - Indicates the ability to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; /** * Starts a new service extension ability. - * - * @since 9 + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ startServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startServiceExtensionAbility(want: Want): Promise; /** * Starts a new service extension ability with account. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @param accountId Indicates the account to start. - * @systemapi hide for inner use. - * @return - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. - * @StageModelOnly + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; /** * Stops a service within the same application. - * - * @since 9 + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ stopServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Stops a service within the same application. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ stopServiceExtensionAbility(want: Want): Promise; /** * Stops a service within the same application with account. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want info to start. - * @param accountId Indicates the accountId to start. - * @systemapi hide for inner use. - * @return - * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. - * @StageModelOnly + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Stops a service within the same application with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; /** * Destroys this service extension. - * - * @since 9 + * @param { AsyncCallback } callback - The callback of terminateSelf. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @systemapi hide for inner use. - * @return - - * @StageModelOnly + * @systemapi + * @stagemodelonly + * @since 9 */ terminateSelf(callback: AsyncCallback): void; + + /** + * Destroys this service extension. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ terminateSelf(): Promise; /** @@ -144,6 +248,8 @@ export default class ServiceExtensionContext extends ExtensionContext { * @systemapi hide for inner use. * @return connection id, int value. * @StageModelOnly + * @deprecated since 9 + * @useinstead connectServiceExtensionAbility */ connectAbility(want: Want, options: ConnectOptions): number; @@ -162,6 +268,8 @@ export default class ServiceExtensionContext extends ExtensionContext { * @systemapi hide for inner use. * @return connection id, int value. * @StageModelOnly + * @deprecated since 9 + * @useinstead connectServiceExtensionAbilityWithAccount */ connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; @@ -175,18 +283,75 @@ export default class ServiceExtensionContext extends ExtensionContext { * @systemapi hide for inner use. * @return - * @StageModelOnly + * @deprecated since 9 + * @useinstead disconnectServiceExtensionAbility */ disconnectAbility(connection: number, callback:AsyncCallback): void; disconnectAbility(connection: number): Promise; /** - * Get the caller object of the startup capability - * + * Connects an ability to a Service extension. + *

          This method can be called by an ability or service extension, but the destination of the connection must be a + * service extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * service extension when the Service extension is connected.

          + * @param { Want } want - Indicates the service extension to connect. + * @param { ConnectOptions } options - Indicates the callback of connection. + * @returns { number } Returns the connection id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly * @since 9 + */ + connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects an ability to a Service extension with account. + *

          This method can be called by an ability or service extension, but the destination of the connection must be a + * service extension. You must implement the {@link ConnectOptions} interface to obtain the proxy of the target + * service extension when the Service extension is connected.

          + * @param { Want } want - Indicates the service extension to connect. + * @param { number } accountId - Indicates the account to connect. + * @param { ConnectOptions } options - Indicates the callback of connection. + * @returns { number } Returns the connection id. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @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 + * @systemapi + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * Disconnects an ability to a service extension, in contrast to {@link connectAbility}. + * @param { number } connection - the connection id returned from connectAbility api. + * @param { AsyncCallback } callback - The callback of disconnectAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback): void; + + /** + * Disconnects an ability to a service extension, in contrast to {@link connectAbility}. + * @param { number } connection - the connection id returned from connectAbility api. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number): Promise; + + /** + * Get the caller object of the startup capability + * @param { Want } want - Indicates the ability to start. + * @returns { Promise } Returns the Caller interface. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 */ - startAbilityByCall(want: Want): Promise; + startAbilityByCall(want: Want): Promise; } \ No newline at end of file diff --git a/api/application/UIAbilityContext.d.ts b/api/application/UIAbilityContext.d.ts new file mode 100755 index 0000000000000000000000000000000000000000..0c5e2e0f64380de329f40b0faf918ac66fb4e65f --- /dev/null +++ b/api/application/UIAbilityContext.d.ts @@ -0,0 +1,522 @@ +/* + * 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 "../bundleManager/abilityInfo"; +import { AbilityResult } from "../ability/abilityResult"; +import { AsyncCallback } from "../basic"; +import { ConnectOptions } from "../ability/connectOptions"; +import { HapModuleInfo } from "../bundleManager/hapModuleInfo"; +import Context from "./Context"; +import Want from "../@ohos.application.Want"; +import StartOptions from "../@ohos.app.ability.StartOptions"; +import PermissionRequestResult from "./PermissionRequestResult"; +import { Configuration } from '../@ohos.app.ability.Configuration'; +import { Caller } from '../@ohos.app.ability.UIAbility'; +import { LocalStorage } from 'StateManagement'; +import image from '../@ohos.multimedia.image'; + +/** + * The context of an ability. It allows access to ability-specific resources. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ +export default class UIAbilityContext extends Context { + /** + * Indicates configuration information about an ability. + * @type { AbilityInfo } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + abilityInfo: AbilityInfo; + + /** + * Indicates configuration information about the module. + * @type { HapModuleInfo } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + currentHapModuleInfo: HapModuleInfo; + + /** + * Indicates configuration information. + * @type { Configuration } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + config: Configuration; + + /** + * Starts a new ability. + * @param want { Want } - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts a new ability. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbility(want: Want, options?: StartOptions): Promise; + + /** + * Get the caller object of the startup capability + * @param { Want } want - Indicates the ability to start. + * @returns { Promise } Returns the Caller interface. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityByCall(want: Want): Promise; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts a new ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbilityForResult(want: Want, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed. + * @param { Want } want - Indicates the ability to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } Returns the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + startAbilityForResult(want: Want, options?: StartOptions): Promise; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; + + /** + * Starts an ability and returns the execution result when the ability is destroyed with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { StartOptions } options - Indicates the start options. + * @returns { Promise } Returns the result of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; + + /** + * Starts a new service extension ability. + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbility(want: Want): Promise; + + /** + * Starts a new service extension ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @param { AsyncCallback } callback - The callback of startServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Starts a new service extension ability with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the account to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; + + /** + * Stops a service within the same application. + * @param { Want } want - Indicates the want info to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbility(want: Want, callback: AsyncCallback): void; + + /** + * Stops a service within the same application. + * @param { Want } want - Indicates the want info to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbility(want: Want): Promise; + + /** + * Stops a service within the same application with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbilityWithAccount. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; + + /** + * Stops a service within the same application with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS. + * @param { Want } want - Indicates the want info to start. + * @param { number } accountId - Indicates the accountId to start. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; + + /** + * Destroys this Page ability. + * @param { AsyncCallback } callback - The callback of terminateSelf. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelf(callback: AsyncCallback): void; + + /** + * Destroys this Page ability. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelf(): Promise; + + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * @param { AbilityResult } parameter - Indicates the result to return. + * @param { AsyncCallback } callback - The callback of terminateSelfWithResult. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback): void; + + /** + * Sets the result code and data to be returned by this Page ability to the caller + * and destroys this Page ability. + * @param { AbilityResult } parameter - Indicates the result to return. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + terminateSelfWithResult(parameter: AbilityResult): Promise; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. + * @param { Want } want - The element name of the service ability + * @param { ConnectOptions } options - The remote object instance + * @returns { number } Returns the number code of the ability connected + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; + + /** + * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template with account. + * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + * @param { Want } want - The element name of the service ability + * @param { number } accountId - The account to connect + * @param { ConnectOptions } options - The remote object instance + * @returns { number } Returns the number code of the ability connected + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; + + /** + * The callback interface is connected successfully. + * @param { number } connection - The number code of the ability connected + * @param { AsyncCallback } callback - The callback of disconnectAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback): void; + + /** + * The callback interface is connected successfully. + * @param { number } connection - The number code of the ability connected + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + disconnectServiceExtensionAbility(connection: number): Promise; + + /** + * Set mission label of current ability. + * @param { string } label - The label of ability that showed in recent missions. + * @param { AsyncCallback } callback - The callback of setMissionLabel. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + setMissionLabel(label: string, callback: AsyncCallback): void; + + /** + * Set mission label of current ability. + * @param { string } label - The label of ability that showed in recent missions. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + setMissionLabel(label: string): Promise; + + /** + * Set mission icon of current ability. + * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. + * @param { AsyncCallback } callback - The callback of setMissionIcon. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + setMissionIcon(icon: image.PixelMap, callback: AsyncCallback): void; + + /** + * Set mission icon of current ability. + * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi + * @stagemodelonly + * @since 9 + */ + setMissionIcon(icon: image.PixelMap): Promise; + + /** + * Requests certain permissions from the system. + * @param { Array } permissions - Indicates the list of permissions to be requested. This parameter + * cannot be null or empty. + * @param { AsyncCallback } requestCallback - The callback is used to return the permission + * request result. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + requestPermissionsFromUser(permissions: Array, requestCallback: AsyncCallback): void; + + /** + * Requests certain permissions from the system. + * @param { Array } permissions - Indicates the list of permissions to be requested. This parameter + * cannot be null or empty. + * @returns { Promise } Returns the permission request result. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + requestPermissionsFromUser(permissions: Array): Promise; + + /** + * Restore window stage data in ability continuation + * @param { LocalStorage } localStorage - the storage data used to restore window stage + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + restoreWindowStage(localStorage: LocalStorage): void; + + /** + * Check to see ability is in terminating state. + * @returns { boolean } Returns true when ability is in terminating state, else returns false. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 9 + */ + isTerminating(): boolean; +} diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index d6e08d73b2da9897b764087e2fb95667bd74c348..0cabc49f0364b8e1056b12ce51cfd5983d19ba30 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -14,8 +14,8 @@ */ import { AsyncCallback } from '../basic'; -import Ability from '../@ohos.application.Ability'; -import AbilityStage from '../@ohos.application.AbilityStage'; +import UIAbility from '../@ohos.app.ability.UIAbility'; +import AbilityStage from '../@ohos.app.ability.AbilityStage'; import { AbilityMonitor } from './abilityMonitor'; import { AbilityStageMonitor } from './abilityStageMonitor'; import Context from './Context'; @@ -24,140 +24,249 @@ import { ShellCmdResult } from './shellCmdResult'; /** * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. - * - * @since 8 + * @interface * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @import import AbilityDelegator from 'application/abilityDelegator.d' - * @permission N/A + * @since 9 */ export interface AbilityDelegator { /** * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. - * - * @since 9 + * @param { AbilityMonitor } monitor - AbilityMonitor object + * @param { AsyncCallback } callback - The callback of addAbilityMonitor. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param monitor AbilityMonitor object + * @since 9 */ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + + /** + * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. + * @param { AbilityMonitor } monitor - AbilityMonitor object + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ addAbilityMonitor(monitor: AbilityMonitor): Promise; /** * Add an AbilityStageMonitor object for monitoring the lifecycle state changes of the specified abilityStage. - * + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @param { AsyncCallback } callback - The callback of addAbilityStageMonitor. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback): void; + + /** + * Add an AbilityStageMonitor object for monitoring the lifecycle state changes of the specified abilityStage. + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param monitor AbilityStageMonitor object + * @since 9 */ - addAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback): void; - addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise; + addAbilityStageMonitor(monitor: AbilityStageMonitor): Promise; /** * Remove a specified AbilityMonitor object from the application memory. - * - * @since 9 + * @param { AbilityMonitor } monitor - AbilityMonitor object. + * @param { AsyncCallback } callback - The callback of removeAbilityMonitor. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param monitor AbilityMonitor object + * @since 9 */ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + + /** + * Remove a specified AbilityMonitor object from the application memory. + * @param { AbilityMonitor } monitor - AbilityMonitor object. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ removeAbilityMonitor(monitor: AbilityMonitor): Promise; /** * Remove a specified AbilityStageMonitor object from the application memory. - * + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @param { AsyncCallback } callback - The callback of removeAbilityStageMonitor. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback): void; + + /** + * Remove a specified AbilityStageMonitor object from the application memory. + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param monitor AbilityStageMonitor object + * @since 9 */ - removeAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback): void; - removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise; + removeAbilityStageMonitor(monitor: AbilityStageMonitor): Promise; /** * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. - * + * @param { AbilityMonitor } monitor - AbilityMonitor object. + * @param { AsyncCallback } callback - The callback is used to return the Ability object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + + /** + * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. + * @param { AbilityMonitor } monitor - AbilityMonitor object. + * @param { number } timeout - Maximum wait time, in milliseconds. + * @param { AsyncCallback } callback - The callback is used to return the Ability object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @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 + * @since 9 */ - waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; - waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; - waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise; + waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; + + /** + * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. + * @param { AbilityMonitor } monitor - AbilityMonitor object. + * @param { number } timeout - Maximum wait time, in milliseconds. + * @returns { Promise } Returns the Ability object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ + waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise; /** * Wait for and returns the AbilityStage object that matches the conditions set in the given AbilityStageMonitor. - * + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @param { AsyncCallback } callback - The callback is used to return the AbilityStage object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback): void; + + /** + * Wait for and returns the AbilityStage object that matches the conditions set in the given AbilityStageMonitor. + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @param { number } timeout - Maximum wait time, in milliseconds. + * @param { AsyncCallback } callback - The callback is used to return the AbilityStage object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param monitor AbilityStageMonitor object - * @param timeout Maximum wait time, in milliseconds - * @return success: return the AbilityStage object, failure: return null + * @since 9 */ - waitAbilityStageMonitor(monitor: AbilityStageMonitor, callback: AsyncCallback): void; - waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: AsyncCallback): void; - waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise; + waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout: number, callback: AsyncCallback): void; /** - * Obtain the application context. - * + * Wait for and returns the AbilityStage object that matches the conditions set in the given AbilityStageMonitor. + * @param { AbilityStageMonitor } monitor - AbilityStageMonitor object. + * @param { number } timeout - Maximum wait time, in milliseconds. + * @returns { Promise } Returns the AbilityStage object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise; + + /** + * Obtain the application context. + * @returns { Context } Returns the app Context. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @return App Context + * @since 9 */ getAppContext(): Context; /** * Obtain the lifecycle state of a specified ability. - * - * @since 9 + * @param { UIAbility } ability - The Ability object. + * @returns { number } Returns the state of the Ability object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param ability The Ability object - * @return The state of the Ability object. enum AbilityLifecycleState + * @since 9 */ - getAbilityState(ability: Ability): number; + getAbilityState(ability: UIAbility): number; /** * Obtain the ability that is currently being displayed. - * + * @param { AsyncCallback } callback - The callback is used to return the Ability object. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + getCurrentTopAbility(callback: AsyncCallback): void; + + /** + * Obtain the ability that is currently being displayed. + * @returns { Promise } Returns the Ability object. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @return The top ability of the current application + * @since 9 */ - getCurrentTopAbility(callback: AsyncCallback): void; - getCurrentTopAbility(): Promise + getCurrentTopAbility(): Promise /** * Start a new ability. - * - * @since 9 + * @param { Want } want - Indicates the ability to start + * @param { AsyncCallback } callback - The callback of startAbility. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the ability to start - * @return - + * @since 9 */ startAbility(want: Want, callback: AsyncCallback): void; + + /** + * Start a new ability. + * @param { Want } want - Indicates the ability to start + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ startAbility(want: Want): Promise; /** * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. - * + * @param { UIAbility } ability - The ability object. + * @param { AsyncCallback } callback - The callback of doAbilityForeground. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + doAbilityForeground(ability: UIAbility, callback: AsyncCallback): void; + + /** + * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. + * @param { UIAbility } ability - The ability object. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param ability The ability object - * @return true: success false: failure + * @since 9 */ - doAbilityForeground(ability: Ability, callback: AsyncCallback): void; - doAbilityForeground(ability: Ability): Promise; + doAbilityForeground(ability: UIAbility): Promise; /** * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. - * + * @param { UIAbility } ability - The ability object. + * @param { AsyncCallback } callback - The callback of doAbilityBackground. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @since 9 + */ + doAbilityBackground(ability: UIAbility, callback: AsyncCallback): void; + + /** + * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. + * @param { UIAbility } ability - The ability object. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param ability The ability object - * @return true: success false: failure + * @since 9 */ - doAbilityBackground(ability: Ability, callback: AsyncCallback): void; - doAbilityBackground(ability: Ability): Promise; + doAbilityBackground(ability: UIAbility): Promise; /** * Prints log information to the unit testing console. @@ -173,12 +282,12 @@ export interface AbilityDelegator { /** * Prints log information to the unit testing console. * The total length of the log information to be printed cannot exceed 1000 characters. - * - * @since 9 + * @param { string } msg - Log information. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param msg Log information + * @since 9 */ - printSync(msg: string): void; + printSync(msg: string): void; /** * Execute the given command in the aa tools side. @@ -196,13 +305,25 @@ export interface AbilityDelegator { /** * 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 + * @param { string } msg - Log information. + * @param { number } code - Result code. + * @param { AsyncCallback } callback - The callback of finishTest. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param msg Log information - * @param code Result code + * @since 9 */ finishTest(msg: string, code: number, callback: AsyncCallback): void; + + /** + * 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. + * @param { string } msg - Log information. + * @param { number } code - Result code. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 401 - If the input parameter is not valid parameter. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 9 + */ finishTest(msg: string, code: number): Promise; } diff --git a/api/application/abilityMonitor.d.ts b/api/application/abilityMonitor.d.ts index 6af8397d2af4374028708d8c240d8dcc38d3f524..0e37ca308da17f3dcc623e66b4b4219f19191bf4 100644 --- a/api/application/abilityMonitor.d.ts +++ b/api/application/abilityMonitor.d.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import Ability from '../@ohos.application.Ability'; +import UIAbility from '../@ohos.app.ability.UIAbility'; /** * Provide methods for matching monitored Ability objects that meet specified conditions. @@ -33,13 +33,21 @@ export interface AbilityMonitor { */ abilityName: string; + /** + * The name of the module to monitor. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + moduleName?: string; + /** * Called back when the ability is started for initialization. * * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityCreate?:(data: Ability) => void; + onAbilityCreate?:(ability: UIAbility) => void; /** * Called back when the state of the ability changes to foreground. @@ -47,7 +55,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityForeground?:(data: Ability) => void; + onAbilityForeground?:(ability: UIAbility) => void; /** * Called back when the state of the ability changes to background. @@ -55,7 +63,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityBackground?:(data: Ability) => void; + onAbilityBackground?:(ability: UIAbility) => void; /** * Called back before the ability is destroyed. @@ -63,7 +71,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onAbilityDestroy?:(data: Ability) => void; + onAbilityDestroy?:(ability: UIAbility) => void; /** * Called back when an ability window stage is created. @@ -71,7 +79,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onWindowStageCreate?:(data: Ability) => void; + onWindowStageCreate?:(ability: UIAbility) => void; /** * Called back when an ability window stage is restored. @@ -79,7 +87,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onWindowStageRestore?:(data: Ability) => void; + onWindowStageRestore?:(ability: UIAbility) => void; /** * Called back when an ability window stage is destroyed. @@ -87,7 +95,7 @@ export interface AbilityMonitor { * @since 9 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - onWindowStageDestroy?:(data: Ability) => void; + onWindowStageDestroy?:(ability: UIAbility) => void; } export default AbilityMonitor; \ No newline at end of file diff --git a/api/bundle/PermissionDef.d.ts b/api/bundle/PermissionDef.d.ts index 6be050d5d9c4f317090f05de501fd41b9ac49346..0f5f91ba384fe2d3032e1c601cb5ce5b3ec05514 100644 --- a/api/bundle/PermissionDef.d.ts +++ b/api/bundle/PermissionDef.d.ts @@ -19,6 +19,8 @@ * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.PermissionDef */ export interface PermissionDef { /** diff --git a/api/bundle/abilityInfo.d.ts b/api/bundle/abilityInfo.d.ts index b1ae1d907f5d8290801f0f1eef179f6ff5ad5a63..582105fe21b85fa297b5c8cd25bfded8227fa154 100644 --- a/api/bundle/abilityInfo.d.ts +++ b/api/bundle/abilityInfo.d.ts @@ -15,7 +15,6 @@ import { ApplicationInfo } from './applicationInfo'; import { CustomizeData } from './customizeData' -import { Metadata } from './metadata' import bundle from './../@ohos.bundle'; /** @@ -23,6 +22,8 @@ import bundle from './../@ohos.bundle'; * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.AbilityInfo */ export interface AbilityInfo { /** @@ -215,67 +216,10 @@ export interface AbilityInfo { */ 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/api/bundle/applicationInfo.d.ts b/api/bundle/applicationInfo.d.ts index 73477bb49bc2aab39ecb3ae0367e76a56f8469fe..6b24191948c3039a28bd876398412fcea0111ba5 100644 --- a/api/bundle/applicationInfo.d.ts +++ b/api/bundle/applicationInfo.d.ts @@ -15,15 +15,14 @@ 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 - * + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.ApplicationInfo */ export interface ApplicationInfo { /** @@ -76,13 +75,6 @@ export interface ApplicationInfo { */ readonly labelId: string; - /** - * @default Indicates the label index of the application - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly labelIndex: number; - /** * @default Indicates the icon of the application * @since 7 @@ -98,13 +90,6 @@ export interface ApplicationInfo { */ readonly iconId: string; - /** - * @default Indicates the icon index of the application - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly iconIndex: number; - /** * @default Process of application, if user do not set it ,the value equal bundleName * @since 7 @@ -161,13 +146,6 @@ export interface ApplicationInfo { */ 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 @@ -195,45 +173,4 @@ export interface ApplicationInfo { * @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/api/bundle/bundleInfo.d.ts b/api/bundle/bundleInfo.d.ts index 4da8310f4300f390e4faf00594cd3c43730c4cca..fe6cf36753dba3878f022f139a02c5d52c7ee751 100644 --- a/api/bundle/bundleInfo.d.ts +++ b/api/bundle/bundleInfo.d.ts @@ -15,7 +15,6 @@ import { AbilityInfo } from './abilityInfo'; import { ApplicationInfo } from './applicationInfo'; -import { ExtensionAbilityInfo } from './extensionAbilityInfo'; import { HapModuleInfo } from './hapModuleInfo'; /** @@ -23,6 +22,8 @@ import { HapModuleInfo } from './hapModuleInfo'; * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.UsedScene * */ export interface UsedScene { @@ -46,7 +47,8 @@ export interface UsedScene { * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA - * + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.ReqPermissionDetail */ export interface ReqPermissionDetail { /** @@ -63,13 +65,6 @@ export interface ReqPermissionDetail { */ 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 @@ -83,7 +78,8 @@ export interface ReqPermissionDetail { * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA - * + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.BundleInfo */ export interface BundleInfo { /** @@ -249,11 +245,4 @@ export interface BundleInfo { * @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/api/bundle/bundleInstaller.d.ts b/api/bundle/bundleInstaller.d.ts index a2e31165f8399857295d904a3bae7aa1c19a3f5d..337ad6bd27c4deee08e9f11e172c28f1809e292d 100644 --- a/api/bundle/bundleInstaller.d.ts +++ b/api/bundle/bundleInstaller.d.ts @@ -16,41 +16,22 @@ import { AsyncCallback } from './../basic'; import bundle from './../@ohos.bundle'; -/** - * @name Provides parameters required for hashParam. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @permission NA - * @systemapi Hide this for inner system use - */ - export interface HashParam { - /** - * @default Indicates the moduleName - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - moduleName: string; - - /** - * @default Indicates the hash value - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - hashValue: string; -} - /** * @name Provides parameters required for installing or uninstalling an application. * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer#InstallParam */ export interface InstallParam { /** * @default Indicates the user id * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 + * @useinstead ohos.bundle.installer.InstallParam#userId */ userId: number; @@ -58,6 +39,8 @@ export interface InstallParam { * @default Indicates the install flag * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 + * @useinstead ohos.bundle.installer.InstallParam#installFlag */ installFlag: number; @@ -65,22 +48,10 @@ export interface InstallParam { * @default Indicates whether the param has data * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 + * @useinstead ohos.bundle.installer.InstallParam#isKeepData */ isKeepData: boolean; - - /** - * @default Indicates the hash params - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - hashParams?: Array; - - /** - * @default Indicates the deadline of the crowdtesting bundle - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - crowdtestDeadline?: number; } /** @@ -89,6 +60,7 @@ export interface InstallParam { * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 */ export interface InstallStatus { @@ -96,6 +68,7 @@ export interface InstallStatus { * @default Indicates the install or uninstall error code * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 */ status: bundle.InstallErrorCode; @@ -103,6 +76,7 @@ export interface InstallStatus { * @default Indicates the install or uninstall result string message * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 */ statusMessage: string; } @@ -113,6 +87,8 @@ export interface InstallStatus { * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer#BundleInstaller */ export interface BundleInstaller { /** @@ -126,6 +102,8 @@ export interface BundleInstaller { * @param installParam Indicates other parameters required for the installation. * @return InstallStatus * @permission ohos.permission.INSTALL_BUNDLE + * @deprecated since 9 + * @useinstead ohos.bundle.installer.BundleInstaller#install */ install(bundleFilePaths: Array, param: InstallParam, callback: AsyncCallback): void; @@ -139,6 +117,8 @@ export interface BundleInstaller { * @param installParam Indicates other parameters required for the uninstallation. * @return InstallStatus * @permission ohos.permission.INSTALL_BUNDLE + * @deprecated since 9 + * @useinstead ohos.bundle.installer.BundleInstaller#uninstall */ uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback): void; @@ -153,6 +133,8 @@ export interface BundleInstaller { * @return InstallStatus * @permission ohos.permission.INSTALL_BUNDLE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer.BundleInstaller#recover */ recover(bundleName: string, param: InstallParam, callback: AsyncCallback): void; } \ No newline at end of file diff --git a/api/bundle/bundleStatusCallback.d.ts b/api/bundle/bundleStatusCallback.d.ts index b5c4d368583d4bffdefc1f34d8fe4d41654cdf0c..7b1a2107dc6b3e194765b94cfc43a1b40822d320 100644 --- a/api/bundle/bundleStatusCallback.d.ts +++ b/api/bundle/bundleStatusCallback.d.ts @@ -23,6 +23,7 @@ * * @permission ohos.permission.LISTEN_BUNDLE_CHANGE * @systemapi Hide this for inner system use + * @deprecated since 9 */ export interface BundleStatusCallback { /** diff --git a/api/bundle/customizeData.d.ts b/api/bundle/customizeData.d.ts index 4427daf06140214d97ac34ea92efb612e3812218..762a082e1ee46c18e23f6ac9a9fb77d4f5c5681d 100644 --- a/api/bundle/customizeData.d.ts +++ b/api/bundle/customizeData.d.ts @@ -18,6 +18,8 @@ * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.Metadata * */ export interface CustomizeData { @@ -27,14 +29,14 @@ * @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 diff --git a/api/bundle/elementName.d.ts b/api/bundle/elementName.d.ts index 3eeff9218e709706e4821e0a0b66f6186e924396..605f8e19efab4f61c696e817e924d5a37a2d3f7d 100644 --- a/api/bundle/elementName.d.ts +++ b/api/bundle/elementName.d.ts @@ -22,6 +22,8 @@ * @syscap SystemCapability.BundleManager.BundleFramework * * @permission N/A + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.ElementName */ export interface ElementName { /** @@ -68,13 +70,4 @@ * @syscap SystemCapability.BundleManager.BundleFramework */ shortName?: string; - - /** - * module name - * @default - - * - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - moduleName?: string; } diff --git a/api/bundle/hapModuleInfo.d.ts b/api/bundle/hapModuleInfo.d.ts index 5ed5be922e699bba39e878bdec513cbdfba1df67..cf1c3282e510ed30a967307f9f352588457d6694 100644 --- a/api/bundle/hapModuleInfo.d.ts +++ b/api/bundle/hapModuleInfo.d.ts @@ -14,15 +14,14 @@ */ 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 - * + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.HapModuleInfo */ export interface HapModuleInfo { /** @@ -115,31 +114,4 @@ export interface HapModuleInfo { * @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; } \ No newline at end of file diff --git a/api/bundle/launcherAbilityInfo.d.ts b/api/bundle/launcherAbilityInfo.d.ts index a73f3ce63f7f6ffc9a3a054479a95437c99d0e72..31438d20dd49bd5cba19b3cd3dc3521c3b013f22 100644 --- a/api/bundle/launcherAbilityInfo.d.ts +++ b/api/bundle/launcherAbilityInfo.d.ts @@ -26,6 +26,8 @@ import { ElementName } from './elementName' * * @permission N/A * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.LauncherAbilityInfo */ export interface LauncherAbilityInfo { /** diff --git a/api/bundle/moduleInfo.d.ts b/api/bundle/moduleInfo.d.ts index f961a10b9d6cabbadef869709aaa1a848f860e43..2f23150f4031dc248cc1e7dfe175a0aa248a40a7 100644 --- a/api/bundle/moduleInfo.d.ts +++ b/api/bundle/moduleInfo.d.ts @@ -18,7 +18,8 @@ * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA - * + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager.HapModuleInfo */ export interface ModuleInfo { /** diff --git a/api/bundle/packInfo.d.ts b/api/bundle/packInfo.d.ts deleted file mode 100644 index 1c4a45903d8717db95af7b2fc2ca5ae93fd72b60..0000000000000000000000000000000000000000 --- a/api/bundle/packInfo.d.ts +++ /dev/null @@ -1,389 +0,0 @@ -/* - * 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 The bundle pack info class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface BundlePackInfo { - /** - * @default This contains package information in pack.info - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly packages: Array; - - /** - * @default This contains bundle summary information in pack.info - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly summary: PackageSummary; -} - -/** - * @name PackageConfig: the package info class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface PackageConfig { - /** - * @default Indicates the device type of this package - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly deviceType: Array; - - /** - * @default Indicates the name of this package - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly name: string; - - /** - * @default Indicates the module type of this package - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly moduleType: string; - - /** - * @default Indicates whether this package is delivery and install - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly deliveryWithInstall: boolean; -} - -/** - * @name PackageSummary: the package summary class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface PackageSummary { - /** - * @default Indicates the bundle config info of this package - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly app: BundleConfigInfo; - - /** - * @default Indicates the modules config info of this package - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly modules: Array; -} - -/** - * @name BundleConfigInfo: the bundle summary class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface BundleConfigInfo { - /** - * @default Indicates the name of this bundle - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly bundleName: string; - - /** - * @default Indicates the bundle version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly version: Version; -} - -/** - * @name ExtensionAbilities: the extension ability forms class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ - export interface ExtensionAbilities { - /** - * @default Indicates the name of this extension ability - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly name: string; - - /** - * @default Indicates the ability forms info - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly forms: Array; -} - -/** - * @name ModuleConfigInfo: the module summary of a bundle. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface ModuleConfigInfo { - /** - * @default Indicates the api version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly apiVersion: ApiVersion; - - /** - * @default Indicates the devices type - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly deviceType: Array; - - /** - * @default Indicates the module distro info - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly distro: ModuleDistroInfo; - - /** - * @default Indicates the abilities info of this module - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly abilities: Array; - - /** - * @default Indicates extension abilities info of this module - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly extensionAbilities: Array; -} - -/** - * @name ModuleDistroInfo: the bundle info summary class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface ModuleDistroInfo { - /** - * @default Indicates the name of main ability - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly mainAbility: string; - - /** - * @default Indicates is delivery with install - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly deliveryWithInstall: boolean; - - /** - * @default Indicates is free install - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly installationFree: boolean; - - /** - * @default Indicates the module name - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly moduleName: string; - - /** - * @default Indicates the module type - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly moduleType: string; -} - -/** - * @name ModuleAbilityInfo: the ability info of a module. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface ModuleAbilityInfo { - /** - * @default Indicates the name of this module ability - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly name: string; - - /** - * @default Indicates the label of this module ability - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly label: string; - - /** - * @default Indicates is visible - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly visible: boolean; - - /** - * @default Indicates the ability forms info - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly forms: Array; -} - -/** - * @name AbilityFormInfo: the form info of an ability. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface AbilityFormInfo { - /** - * @default Indicates the name of this ability - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly name: string; - - /** - * @default Indicates the type of this ability - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly type: string; - - /** - * @default Indicates is enabled update - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly updateEnabled: boolean; - - /** - * @default Indicates the scheduled update time - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly scheduledUpdateTime: string; - - /** - * @default Indicates the update duration - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly updateDuration: number; - - /** - * @default Indicates the ability support dimensions - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly supportDimensions: Array; - - /** - * @default Indicates the ability default dimension - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly defaultDimension: number; -} - -/** - * @name Version: the bundle version class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface Version { - /** - * @default Indicates the min compatible code of this version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly minCompatibleVersionCode: number; - - /** - * @default Indicates the name of this version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly name: string; - - /** - * @default Indicates the code of this version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly code: number; -} - -/** - * @name ApiVersion: the bundle Api version class. - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - * @systemapi hide this for inner system use - */ -export interface ApiVersion { - /** - * @default Indicates the min compatible code of this version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly releaseType: string; - - /** - * @default Indicates the name of this version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly compatible: number; - - /** - * @default Indicates the code of this version - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly target: number; -} - -/** -* @name BundlePackFlag -* @since 9 -* @syscap SystemCapability.BundleManager.BundleFramework -* @import NA -* @systemapi hide this for inner system use -*/ -export enum BundlePackFlag { - GET_PACK_INFO_ALL = 0x00000000, - GET_PACKAGES = 0x00000001, - GET_BUNDLE_SUMMARY = 0x00000002, - GET_MODULE_SUMMARY = 0x00000004, -} \ No newline at end of file diff --git a/api/bundle/remoteAbilityInfo.d.ts b/api/bundle/remoteAbilityInfo.d.ts index e9a1585c266935fe61704347a15a25eaebd4ccb3..176c28d96980100c266d52e1a3dbe5caed24edc8 100644 --- a/api/bundle/remoteAbilityInfo.d.ts +++ b/api/bundle/remoteAbilityInfo.d.ts @@ -22,6 +22,8 @@ import { ElementName } from './elementName'; * @systemapi * * @permission N/A + * @deprecated since 9 + * @useinstead ohos.bundle.distributedBundle.RemoteAbilityInfo */ export interface RemoteAbilityInfo { /** diff --git a/api/bundle/shortcutInfo.d.ts b/api/bundle/shortcutInfo.d.ts index 98c0a85563cd95a2dad1f72bd0a3305fe0fc7a15..cc3bf4332619665cd51ab06a6495af3882778f16 100644 --- a/api/bundle/shortcutInfo.d.ts +++ b/api/bundle/shortcutInfo.d.ts @@ -20,6 +20,8 @@ * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.launcherBundleManager.ShortcutWant */ export interface ShortcutWant{ /** @@ -28,12 +30,6 @@ * @syscap SystemCapability.BundleManager.BundleFramework */ readonly targetBundle: string; - /** - * @default Indicates the target module of the shortcut want - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly targetModule: string; /** * @default Indicates the target class of the shortcut want * @since 7 @@ -47,13 +43,15 @@ * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA - * + * @deprecated since 9 + * @useinstead ohos.bundle.launcherBundleManager.ShortcutInfo */ export interface ShortcutInfo { /** * @default Indicates the ID of the application to which this shortcut belongs * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * */ readonly id: string; /** @@ -75,7 +73,7 @@ */ readonly icon: string; /** - * @default Indicate s the icon id of the shortcut + * @default Indicates the icon id of the shortcut * @since 8 * @syscap SystemCapability.BundleManager.BundleFramework */ @@ -122,11 +120,4 @@ * @syscap SystemCapability.BundleManager.BundleFramework */ readonly isEnabled?: boolean; - - /** - * @default Indicates the moduleName of the shortcut - * @since 9 - * @syscap SystemCapability.BundleManager.BundleFramework - */ - readonly moduleName?: string; } \ No newline at end of file diff --git a/api/bundleManager/abilityInfo.d.ts b/api/bundleManager/abilityInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5fe7f0a7bef5eb5713682e64d6d5613397922c1a --- /dev/null +++ b/api/bundleManager/abilityInfo.d.ts @@ -0,0 +1,278 @@ +/* + * 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 { ApplicationInfo } from './applicationInfo'; +import { Metadata } from './metadata'; +import bundleManager from './../@ohos.bundle.bundleManager'; + +/** + * Obtains configuration information about an ability + * @typedef AbilityInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface AbilityInfo { + /** + * Indicates the name of the bundle containing the ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly bundleName: string; + + /** + * Indicates the name of the .hap package to which the capability belongs + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly moduleName: string; + + /** + * Ability simplified class name + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly name: string; + + /** + * Indicates the label of the ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly label: string; + + /** + * Indicates the label id of the ability + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly labelId: number; + + /** + * Indicates the ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly description: string; + + /** + * Indicates the description id of the ability + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly descriptionId: number; + + /** + * Indicates the icon of the ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly icon: string; + + /** + * Indicates the icon id of the ability + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly iconId: number; + + /** + * Process of ability, if user do not set it, the value equal application process + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly process: string; + + /** + * Indicates whether an ability can be called by other abilities + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly isVisible: boolean; + + /** + * Enumerates types of templates that can be used by an ability + * @type {bundleManager.AbilityType} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @FAModelOnly + * @since 9 + */ + readonly type: bundleManager.AbilityType; + + /** + * Enumerates ability display orientations + * @type {bundleManager.DisplayOrientation} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly orientation: bundleManager.DisplayOrientation; + + /** + * Enumerates ability launch type + * @type {bundleManager.LaunchType} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly launchType: bundleManager.LaunchType; + + /** + * The permissions that others need to launch this ability + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly permissions: Array; + + /** + * Indicates the permission required for reading ability data + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @FAModelOnly + * @since 9 + */ + readonly readPermission: string; + + /** + * Indicates the permission required for writing data to the ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @FAModelOnly + * @since 9 + */ + readonly writePermission: string; + + /** + * Uri of ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @FAModelOnly + * @since 9 + */ + readonly uri: string; + + /** + * The device types that this ability can run on + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly deviceTypes: Array; + + /** + * Obtains configuration information about an application + * @type {ApplicationInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly applicationInfo: ApplicationInfo; + + /** + * Indicates the metadata of ability + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly metadata: Array; + + /** + * Indicates whether the ability is enabled + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly enabled: boolean; + + /** + * Indicates which window mode is supported + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly supportWindowModes: Array; + + /** + * Indicates window size + * @type {WindowSize} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly windowSize: WindowSize; +} + +/** + * Indicates the window size. + * @typedef WindowSize + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface WindowSize { + /** + * Indicates maximum ratio of width over height of window under free window status. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly maxWindowRatio: number; + + /** + * Indicates minimum ratio of width over height of window under free window status. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly minWindowRatio: number; + + /** + * Indicates maximum width of window under free window status. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly maxWindowWidth: number; + + /** + * Indicates minimum width of window under free window status. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly minWindowWidth: number; + + /** + * Indicates maximum height of window under free window status. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly maxWindowHeight: number; + + /** + * Indicates minimum height of window under free window status. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly minWindowHeight: number; +} diff --git a/api/bundleManager/applicationInfo.d.ts b/api/bundleManager/applicationInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..881fb3c9aaf66e413173852f4f5f79644ea359ce --- /dev/null +++ b/api/bundleManager/applicationInfo.d.ts @@ -0,0 +1,193 @@ +/* + * 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 { Metadata } from './metadata'; +import { Resource } from '../global/resource'; + +/** + * Obtains configuration information about an application + * @typedef ApplicationInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface ApplicationInfo { + /** + * Indicates the application name, which is the same as {@code bundleName} + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly name: string; + + /** + * Description of application + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly description: string; + + /** + * Indicates the description id of the application + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly descriptionId: number; + + /** + * Indicates whether or not this application may be instantiated + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly enabled: boolean; + + /** + * Indicates the label of the application + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly label: string; + + /** + * Indicates the label id of the application + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly labelId: number; + + /** + * Indicates the icon of the application + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly icon: string; + + /** + * Indicates the icon id of the application + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly iconId: number; + + /** + * Process of application, if user do not set it ,the value equal bundleName + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly process: string; + + /** + * Indicates the permissions required for accessing the application. + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly permissions: Array; + + /** + * Indicates the path where the {@code Entry.hap} file of the application is saved + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly entryDir: string; + + /** + * Indicates the application source code path + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly codePath: string; + + /** + * Indicates the metadata of module + * @type {Map>} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly metadata: Map>; + + /** + * Indicates whether or not this application may be removable + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly removable: boolean; + + /** + * Indicates the access token of the application + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly accessTokenId: number; + + /** + * Indicates the uid of the application + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly uid: number; + + /** + * Indicates icon resource of the application + * @type {Resource} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly iconResource: Resource; + + /** + * Indicates label resource of the application + * @type {Resource} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly labelResource: Resource; + + /** + * Indicates description resource of the application + * @type {Resource} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly descriptionResource: Resource; + + /** + * Indicates the appDistributionType of the application + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly appDistributionType: string; + + /** + * Indicates the appProvisionType of the application + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly appProvisionType: string; +} diff --git a/api/bundleManager/bundleInfo.d.ts b/api/bundleManager/bundleInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a594847041883d385078623de4fc1b943d74a10f --- /dev/null +++ b/api/bundleManager/bundleInfo.d.ts @@ -0,0 +1,219 @@ +/* + * 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 { ApplicationInfo } from './applicationInfo'; +import { HapModuleInfo } from './hapModuleInfo'; +import bundleManager from './../@ohos.bundle.bundleManager'; + +/** + * Obtains configuration information about a bundle + * @typedef BundleInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface BundleInfo { + /** + * Indicates the name of this bundle + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly name: string; + + /** + * Indicates the bundle vendor + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly vendor: string; + + /** + * Indicates the version code of the bundle + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly versionCode: number; + + /** + * Indicates the version name of the bundle + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly versionName: string; + + /** + * Indicates the **minimum ** version compatible with the bundle + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly minCompatibleVersionCode: number; + + /** + * Indicates the target version number of the bundle + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly targetVersion: number; + + /** + * Obtains configuration information about an application + * @type {ApplicationInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly appInfo: ApplicationInfo; + + /** + * Obtains configuration information about an module + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly hapModulesInfo: Array; + + /** + * Indicates the required permissions details defined in file config.json + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly reqPermissionDetails: Array; + + /** + * Indicates the grant state of required permissions + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly permissionGrantStates: Array; + + /** + * Indicates the SignatureInfo of the bundle + * @type {SignatureInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly signatureInfo: SignatureInfo; + + /** + * Indicates the hap install time + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly installTime: number; + + /** + * Indicates the hap update time + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly updateTime: number; +} + +/** + * Indicates the required permissions details defined in configuration file + * @typedef ReqPermissionDetail + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface ReqPermissionDetail { + /** + * Indicates the name of this required permissions + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + name: string; + + /** + * Indicates the reason of this required permissions + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + reason: string; + + /** + * Indicates the reason id of this required permissions + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + reasonId: number; + + /** + * Indicates the used scene of this required permissions + * @type {UsedScene} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + usedScene: UsedScene; +} + +/** + * The scene which is used + * @typedef UsedScene + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface UsedScene { + /** + * Indicates the abilities that need the permission + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + abilities: Array; + + /** + * Indicates the time when the permission is used + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + when: string; +} + +/** + * Indicates SignatureInfo + * @typedef SignatureInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface SignatureInfo { + /** + * 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 + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly appId: string; + + /** + * Indicates the fingerprint of the certificate + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly fingerprint: string; +} \ No newline at end of file diff --git a/api/bundleManager/dispatchInfo.d.ts b/api/bundleManager/dispatchInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f734e8d903d5222890df5df87f122d764a581c3 --- /dev/null +++ b/api/bundleManager/dispatchInfo.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. + */ + +/** + * Dispatch info related to free install + * @typedef DispatchInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface DispatchInfo { + /** + * Indicates the dispatchInfo version + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly version: string; + + /** + * Indicates the free install interface version + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly dispatchAPIVersion: string; +} diff --git a/api/bundleManager/elementName.d.ts b/api/bundleManager/elementName.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..612986c3e584c2d5a30605b1d5c28ae6340bf63b --- /dev/null +++ b/api/bundleManager/elementName.d.ts @@ -0,0 +1,72 @@ +/* + * 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. + */ + +/** + * 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. + * @typedef ElementName + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface ElementName { + /** + * Indicates device id + * @type {?string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + deviceId?: string; + + /** + * @default Indicates bundle name + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + bundleName: string; + + /** + * @default Indicates module name + * @type {?string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + moduleName?: string; + + /** + * Indicates ability name + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + abilityName: string; + + /** + * Indicates uri + * @type {?string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + uri?: string; + + /** + * Indicates short name + * @type {?string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + shortName?: string; +} diff --git a/api/bundle/extensionAbilityInfo.d.ts b/api/bundleManager/extensionAbilityInfo.d.ts similarity index 30% rename from api/bundle/extensionAbilityInfo.d.ts rename to api/bundleManager/extensionAbilityInfo.d.ts index c533ad6dc54b7aab9eb928e0b6be0940c01001f5..e6eaf60187c13976423ebae23e18ae3c7adf2bc0 100644 --- a/api/bundle/extensionAbilityInfo.d.ts +++ b/api/bundleManager/extensionAbilityInfo.d.ts @@ -1,125 +1,138 @@ -/* - * 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; -} +/* + * 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 { ApplicationInfo } from './applicationInfo'; +import { Metadata } from './metadata'; +import bundleManager from './../@ohos.bundle.bundleManager'; + +/** + * Extension information about a bundle + * @typedef ExtensionAbilityInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface ExtensionAbilityInfo { + /** + * Indicates the name of the bundle + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly bundleName: string; + + /** + * Indicates the name of the module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly moduleName: string; + + /** + * Indicates the name of the extension ability info + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly name: string; + + /** + * Indicates the label id of the extension ability info + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly labelId: number; + + /** + * Indicates the description id of the extension ability info + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly descriptionId: number; + + /** + * Indicates the icon id of the extension ability info + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly iconId: number; + + /** + * Indicates whether the extension ability info can be visible or not + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly isVisible: boolean; + + /** + * Enumerates types of the extension ability info + * @type {bundleManager.ExtensionAbilityType} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly extensionAbilityType: bundleManager.ExtensionAbilityType; + + /** + * The permissions that others need to use this extension ability info + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly permissions: Array; + + /** + * Obtains configuration information about an application + * @type {ApplicationInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly applicationInfo: ApplicationInfo; + + /** + * Indicates the metadata of bundle + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly metadata: Array; + + /** + * Indicates the src language to express extension ability info + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly enabled: boolean; + + /** + * Indicates the read permission extension ability info + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly readPermission: string; + + /** + * Indicates the write permission of extension ability info + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly writePermission: string; +} diff --git a/api/bundleManager/hapModuleInfo.d.ts b/api/bundleManager/hapModuleInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6d54b5110297cf7fd003292ee33fe50eae06d1e4 --- /dev/null +++ b/api/bundleManager/hapModuleInfo.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. + */ + +import { AbilityInfo } from "./abilityInfo"; +import { ExtensionAbilityInfo } from "./extensionAbilityInfo"; +import { Metadata } from './metadata' + +/** + * Obtains configuration information about a hap module. + * @typedef HapModuleInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +export interface HapModuleInfo { + /** + * Indicates the name of this hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly name: string; + + /** + * Indicates the icon of this hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly icon: string; + + /** + * Indicates the icon id of this hap module + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly iconId: number; + + /** + * Indicates the label of this hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly label: string; + + /** + * Indicates the label id of this hap module + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly labelId: number; + + /** + * Describes the hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly description: string; + + /** + * Indicates the description of this hap module + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly descriptionId: number; + + /** + * Indicates main elementName of the hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly mainElementName: string; + + /** + * Obtains configuration information about abilities + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly abilitiesInfo: Array; + + /** + * Obtains configuration information about extension abilities + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly extensionAbilitiesInfo: Array; + + /** + * Indicates the metadata of ability + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly metadata: Array; + + /** + * The device types that this hap module can run on + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly deviceTypes: Array; + + /** + * Indicates whether free installation of the hap module is supported + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly installationFree: boolean; + + /** + * Indicates the hash value of the hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly hashValue: string; + + /** + * Indicates the module source dir of this hap module + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly moduleSourceDir: string; +} diff --git a/api/bundleManager/launcherAbilityInfo.d.ts b/api/bundleManager/launcherAbilityInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0fb9f55e8b02fa4bcd2d4b5d5d54dfeed2d22b2b --- /dev/null +++ b/api/bundleManager/launcherAbilityInfo.d.ts @@ -0,0 +1,74 @@ +/* + * 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 { ApplicationInfo } from './applicationInfo'; +import { ElementName } from './elementName' + +/** + * Contains basic launcher Ability information, which uniquely identifies an LauncherAbilityInfo + * @typedef LauncherAbilityInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ +export interface LauncherAbilityInfo { + /** + * Obtains application info information about an launcher ability. + * @type {ApplicationInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly applicationInfo: ApplicationInfo; + + /** + * Obtains element name about an launcher ability. + * @type {ElementName} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly elementName : ElementName; + + /** + * Obtains labelId about an launcher ability. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly labelId: number; + + /** + * Obtains iconId about an launcher ability. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly iconId: number; + + /** + * Obtains userId about an launcher ability. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly userId: number; + + /** + * Obtains installTime about an launcher ability. + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly installTime : number; +} diff --git a/api/bundle/metadata.d.ts b/api/bundleManager/metadata.d.ts similarity index 57% rename from api/bundle/metadata.d.ts rename to api/bundleManager/metadata.d.ts index 4fba45c5348ca3d4806cf46783ba4570b1c7e6c3..4a9e28b748dea9e328f98ea442c9b553cae3b07e 100644 --- a/api/bundle/metadata.d.ts +++ b/api/bundleManager/metadata.d.ts @@ -1,44 +1,46 @@ -/* - * 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; +/* + * 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 Metadata + * @typedef Metadata + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + export interface Metadata { + /** + * Indicates the metadata name + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + name: string; + + /** + * Indicates the metadata value + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + value: string; + + /** + * Indicates the metadata resource + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + resource: string; } \ No newline at end of file diff --git a/api/bundleManager/packInfo.d.ts b/api/bundleManager/packInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c5a359d3906784fb28680b5c97bbf207a45c559 --- /dev/null +++ b/api/bundleManager/packInfo.d.ts @@ -0,0 +1,425 @@ +/* + * 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 bundle pack info class. + * @typedef BundlePackInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface BundlePackInfo { + /** + * This contains package information in pack.info + * @type {PackageConfig} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly packages: Array; + + /** + * This contains bundle summary information in pack.info + * @type {PackageSummary} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly summary: PackageSummary; +} + +/** + * PackageConfig: the package info class. + * @typedef PackageConfig + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface PackageConfig { + /** + * Indicates the device types of this package + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly deviceTypes: Array; + + /** + * Indicates the name of this package + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly name: string; + + /** + * Indicates the module type of this package + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly moduleType: string; + + /** + * Indicates whether this package is delivery and install + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly deliveryWithInstall: boolean; +} + +/** + * PackageSummary: the package summary class. + * @typedef PackageSummary + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface PackageSummary { + /** + * Indicates the bundle config info of this package + * @type {BundleConfigInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly app: BundleConfigInfo; + + /** + * Indicates the modules config info of this package + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly modules: Array; +} + +/** + * BundleConfigInfo: the bundle summary class. + * @typedef BundleConfigInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface BundleConfigInfo { + /** + * Indicates the name of this bundle + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly bundleName: string; + + /** + * Indicates the bundle version + * @type {Version} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly version: Version; +} + +/** + * ExtensionAbility: the extension ability forms class. + * @typedef ExtensionAbility + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ + export interface ExtensionAbility { + /** + * Indicates the name of this extension ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly name: string; + + /** + * Indicates the ability forms info + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly forms: Array; +} + +/** + * ModuleConfigInfo: the module summary of a bundle. + * @typedef ModuleConfigInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface ModuleConfigInfo { + /** + * Indicates the name of main ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly mainAbility: string; + + /** + * Indicates the api version + * @type {ApiVersion} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly apiVersion: ApiVersion; + + /** + * Indicates the devices type + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly deviceTypes: Array; + + /** + * Indicates the module distro info + * @type {ModuleDistroInfo} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly distro: ModuleDistroInfo; + + /** + * Indicates the abilities info of this module + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly abilities: Array; + + /** + * Indicates extension abilities info of this module + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly extensionAbilities: Array; +} + +/** + * ModuleDistroInfo: the bundle info summary class. + * @typedef ModuleDistroInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface ModuleDistroInfo { + /** + * Indicates whether this package is delivered with install + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly deliveryWithInstall: boolean; + + /** + * Indicates whether this package is free install + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly installationFree: boolean; + + /** + * Indicates the module name + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly moduleName: string; + + /** + * Indicates the module type + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly moduleType: string; +} + +/** + * ModuleAbilityInfo: the ability info of a module. + * @typedef ModuleAbilityInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface ModuleAbilityInfo { + /** + * Indicates the name of this module ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly name: string; + + /** + * Indicates the label of this module ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly label: string; + + /** + * Indicates whether this ability is visible + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly visible: boolean; + + /** + * Indicates the ability forms info + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly forms: Array; +} + +/** + * AbilityFormInfo: the form info of an ability. + * @typedef AbilityFormInfo + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface AbilityFormInfo { + /** + * Indicates the name of this ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly name: string; + + /** + * Indicates the type of this ability + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly type: string; + + /** + * Indicates whether this form is enabled update + * @type {boolean} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly updateEnabled: boolean; + + /** + * Indicates the scheduled update time + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly scheduledUpdateTime: string; + + /** + * Indicates the update duration + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly updateDuration: number; + + /** + * Indicates the ability support dimensions + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly supportDimensions: Array; + + /** + * Indicates the ability default dimension + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly defaultDimension: string; +} + +/** + * Version: the bundle version class. + * @typedef Version + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface Version { + /** + * Indicates the min compatible code of this version + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly minCompatibleVersionCode: number; + + /** + * Indicates the name of this version + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly name: string; + + /** + * Indicates the code of this version + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly code: number; +} + +/** + * ApiVersion: the bundle Api version class. + * @typedef ApiVersion + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @systemapi + * @since 9 + */ +export interface ApiVersion { + /** + * Indicates the release type of the api + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly releaseType: string; + + /** + * Indicates the compatible version code of the api + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly compatible: number; + + /** + * Indicates the target version code of the api + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall + * @since 9 + */ + readonly target: number; +} diff --git a/api/bundleManager/permissionDef.d.ts b/api/bundleManager/permissionDef.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..56aa968b62463e2edf6464d5dd655f2fd6686642 --- /dev/null +++ b/api/bundleManager/permissionDef.d.ts @@ -0,0 +1,55 @@ +/* + * 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 defined permission details in file config.json + * @typedef PermissionDef + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + export interface PermissionDef { + /** + * Indicates the name of this permission + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly permissionName: string; + + /** + * Indicates the grant mode of this permission + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly grantMode: number; + + /** + * Indicates the labelId of this permission + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly labelId: number; + + /** + * Indicates the descriptionId of this permission + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + readonly descriptionId: number; + } \ No newline at end of file diff --git a/api/bundleManager/remoteAbilityInfo.d.ts b/api/bundleManager/remoteAbilityInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16b91e764145cafa3951ae58a554bee555f6f55c --- /dev/null +++ b/api/bundleManager/remoteAbilityInfo.d.ts @@ -0,0 +1,49 @@ +/* + * 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 { ElementName } from './elementName'; + +/** + * Contains basic remote ability information. + * @typedef RemoteAbilityInfo + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @systemapi + * @since 9 + */ +export interface RemoteAbilityInfo { + /** + * Indicates the ability information + * @type {ElementName} + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @since 9 + */ + readonly elementName: ElementName; + + /** + * Indicates the label of the ability + * @type {string} + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @since 9 + */ + readonly label: string; + + /** + * Indicates the icon of the ability + * @type {string} + * @syscap SystemCapability.BundleManager.DistributedBundleFramework + * @since 9 + */ + readonly icon: string; +} \ No newline at end of file diff --git a/api/bundleManager/shortcutInfo.d.ts b/api/bundleManager/shortcutInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..85d95df447e10a1fe86fee2325b9fdef637c8e8c --- /dev/null +++ b/api/bundleManager/shortcutInfo.d.ts @@ -0,0 +1,128 @@ +/* + * 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 information about a shortcut, including the shortcut ID and label. + * @typedef ShortcutInfo + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + export interface ShortcutInfo { + /** + * Indicates the ID of the application to which this shortcut belongs + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly id: string; + + /** + * Indicates the name of the bundle containing the shortcut + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly bundleName: string; + + /** + * Indicates the moduleName of the shortcut + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly moduleName: string; + + /** + * Indicates the host ability of the shortcut + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly hostAbility: string; + + /** + * Indicates the icon of the shortcut + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly icon: string; + + /** + * Indicates the icon id of the shortcut + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly iconId: number; + + /** + * Indicates the label of the shortcut + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly label: string; + + /** + * Indicates the label id of the shortcut + * @type {number} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly labelId: number; + + /** + * Indicates the wants of the shortcut + * @type {Array} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly wants: Array; + } + + /** + * Obtains information about the ability that a shortcut will start. + * @typedef ShortcutWant + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @systemapi + * @since 9 + */ + export interface ShortcutWant{ + /** + * Indicates the target bundle of the shortcut want + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly targetBundle: string; + + /** + * Indicates the target module of the shortcut want + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly targetModule: string; + + /** + * Indicates the target ability of the shortcut want + * @type {string} + * @syscap SystemCapability.BundleManager.BundleFramework.Launcher + * @since 9 + */ + readonly targetAbility: string; + } \ No newline at end of file diff --git a/api/common/lite/viewmodel.d.ts b/api/common/lite/viewmodel.d.ts index bd234589864d362a5202097c4f3e5518cc755caa..abb1309d472e341185ff02046fa7e65e31467b88 100644 --- a/api/common/lite/viewmodel.d.ts +++ b/api/common/lite/viewmodel.d.ts @@ -109,10 +109,30 @@ export interface Options> { onDestroy?(): void; } +/** + * Used for ide. + * @systemapi + * @hide + * @since 4 + */ type DefaultData = object; + +/** + * Used for ide. + * @systemapi + * @hide + * @since 4 + */ type CombinedOptions = object & Options & ThisType; + +/** + * @syscap SystemCapability.ArkUI.ArkUI.Lite + * @systemapi + * @hide + * @since 4 + */ export declare function extendViewModel( options: CombinedOptions ): ViewModel & Data; diff --git a/api/data/rdb/resultSet.d.ts b/api/data/rdb/resultSet.d.ts index bfc91c34fbe45aa500ae836b78546663ec3d4f3a..8b080538fff8dc240d38bb1f31c5be9690b0abe9 100755 --- a/api/data/rdb/resultSet.d.ts +++ b/api/data/rdb/resultSet.d.ts @@ -18,18 +18,23 @@ import { AsyncCallback } from '../../basic' /** * Provides methods for accessing a database result set generated by querying the database. * - * @since 7 - * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9 */ -export interface ResultSet { + interface ResultSet { + /** * Obtains the names of all columns in a result set. * * @note The column names are returned as a string array, in which the strings are in the same order * as the columns in the result set. - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.columnNames */ columnNames: Array; @@ -38,8 +43,10 @@ export interface ResultSet { * * @note The returned number is equal to the length of the string array returned by the * columnCount method. - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.columnCount */ columnCount: number; @@ -47,8 +54,10 @@ export interface ResultSet { * Obtains the number of rows in the result set. * * @note N/A - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.rowCount */ rowCount: number; @@ -56,8 +65,10 @@ export interface ResultSet { * Obtains the current index of the result set. * * @note The result set index starts from 0. - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.rowIndex */ rowIndex: number; @@ -65,8 +76,10 @@ export interface ResultSet { * Checks whether the result set is positioned at the first row. * * @note N/A - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.isAtFirstRow */ isAtFirstRow: boolean; @@ -74,8 +87,10 @@ export interface ResultSet { * Checks whether the result set is positioned at the last row. * * @note N/A - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.isAtLastRow */ isAtLastRow: boolean; @@ -83,18 +98,22 @@ export interface ResultSet { * Checks whether the result set is positioned after the last row. * * @note N/A - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.isEnded */ isEnded: boolean; /** - * Returns whether the cursor is pointing to the position before the first + * returns whether the cursor is pointing to the position before the first * row. * * @note N/A - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.isStarted */ isStarted: boolean; @@ -104,8 +123,10 @@ export interface ResultSet { * If the result set is closed by calling the close method, true will be returned. * * @note N/A - * @since 7 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.isClosed */ isClosed: boolean; @@ -113,10 +134,12 @@ export interface ResultSet { * Obtains the column index based on the specified column name. * * @note The column name is passed as an input parameter. - * @since 7 + * @param {string} columnName - Indicates the name of the specified column in the result set. + * @returns {number} return the index of the specified column. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnName Indicates the name of the specified column in the result set. - * @return Returns the index of the specified column. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.getColumnIndex */ getColumnIndex(columnName: string): number; @@ -124,10 +147,294 @@ export interface ResultSet { * Obtains the column name based on the specified column index. * * @note The column index is passed as an input parameter. + * @param {number} columnIndex - Indicates the index of the specified column in the result set. + * @returns {string} returns the name of the specified column. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.getColumnName + */ + getColumnName(columnIndex: number): string; + + /** + * 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. + * + * @note N/A + * @param {number} offset - Indicates the offset relative to the current position. + * @returns {string} returns true if the result set is moved successfully and does not go beyond the range; + * returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.goTo + */ + goTo(offset: number): boolean; + + /** + * Go to the specified row of the result set. + * + * @note N/A + * @param {number} rowIndex - Indicates the index of the specified row, which starts from 0. + * @returns {boolean} returns true if the result set is moved successfully; returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.goToRow + */ + goToRow(position: number): boolean; + + /** + * Go to the first row of the result set. + * + * @note N/A + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.goToFirstRow + */ + goToFirstRow(): boolean; + + /** + * Go to the last row of the result set. + * + * @note N/A + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.goToLastRow + */ + goToLastRow(): boolean; + + /** + * Go to the next row of the result set. + * + * @note N/A + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the last row. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.goToNextRow + */ + goToNextRow(): boolean; + + /** + * Go to the previous row of the result set. + * + * @note N/A + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the first row. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.goToPreviousRow + */ + goToPreviousRow(): boolean; + + /** + * Obtains the value of the specified column 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 + * in the current row is null or the specified column is not of the Blob type. + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {Uint8Array} returns the value of the specified column as a byte array. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.getBlob + */ + getBlob(columnIndex: number): Uint8Array; + + /** + * Obtains the value of the specified column in the current row as string. + * + * @note The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null or the specified column is not of the string type. + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {string} returns the value of the specified column as a string. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.getString + */ + getString(columnIndex: number): string; + + /** + * Obtains the value of the specified column in the current row as long. + * + * @note The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null, the specified column is not of the integer type. + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {number} returns the value of the specified column as a long. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnIndex Indicates the index of the specified column in the result set. - * @return Returns the name of the specified column. + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.getLong + */ + getLong(columnIndex: number): number; + + /** + * Obtains the value of the specified column in the current row as double. + * + * @note The implementation class determines whether to throw an exception if the value of the specified column + * in the current row is null, the specified column is not of the double type. + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {number} returns the value of the specified column as a double. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.getDouble + */ + getDouble(columnIndex: number): number; + + /** + * Checks whether the value of the specified column in the current row is null. + * + * @note N/A + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {boolean} returns true if the value of the specified column in the current row is null; + * returns false otherwise. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.isColumnNull + */ + isColumnNull(columnIndex: number): boolean; + + /** + * Closes the result set. + * + * @note Calling this method on the result set will release all of its resources and makes it ineffective. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 7 + * @deprecated since 9 + * @useinstead ohos.data.rdb.ResultSetV9.close + */ + close(): void; +} + +/** + * Provides methods for accessing a database result set generated by querying the database. + * + * @import import data_rdb from '@ohos.data.rdb'; + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + interface ResultSetV9 { + + /** + * Obtains the names of all columns in a result set. + * + * @note The column names are returned as a string array, in which the strings are in the same order + * as the columns in the result set. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + columnNames: Array; + + /** + * Obtains the number of columns 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.RelationalStore.Core + */ + columnCount: number; + + /** + * Obtains the number of rows in the result set. + * + * @note N/A + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + rowCount: number; + + /** + * Obtains the current index of the result set. + * + * @note The result set index starts from 0. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + rowIndex: number; + + /** + * Checks whether the result set is positioned at the first row. + * + * @note N/A + * @since 9 + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + */ + isAtFirstRow: boolean; + + /** + * Checks whether the result set is positioned at the last row. + * + * @note N/A + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isAtLastRow: boolean; + + /** + * Checks whether the result set is positioned after the last row. + * + * @note N/A + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isEnded: boolean; + + /** + * Returns whether the cursor is pointing to the position before the first row. + * + * @note N/A + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isStarted: boolean; + + /** + * Checks whether the current result set is closed. + * + * If the result set is closed by calling the close method, true will be returned. + * + * @note N/A + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + isClosed: boolean; + + /** + * Obtains the column index based on the specified column name. + * + * @note The column name is passed as an input parameter. + * @param {string} columnName - Indicates the name of the specified column in the result set. + * @returns {number} return the index of the specified column. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - the parameter check failed. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 + */ + getColumnIndex(columnName: string): number; + + /** + * Obtains the column name based on the specified column index. + * + * @note The column index is passed as an input parameter. + * @param {number} columnIndex - Indicates the index of the specified column in the result set. + * @returns {string} returns the name of the specified column. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. + * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core + * @since 9 */ getColumnName(columnIndex: number): string; @@ -136,11 +443,13 @@ export interface ResultSet { * A positive offset indicates moving backwards, and a negative offset indicates moving forwards. * * @note N/A - * @since 7 + * @param {number} offset - Indicates the offset relative to the current position. + * @returns {string} returns true if the result set is moved successfully and does not go beyond the range; + * returns false otherwise. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @throws {BusinessError} 401 - Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.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. + * @since 9 */ goTo(offset: number): boolean; @@ -148,10 +457,12 @@ export interface ResultSet { * Go to the specified row of the result set. * * @note N/A - * @since 7 + * @param {number} rowIndex - Indicates the index of the specified row, which starts from 0. + * @returns {boolean} returns true if the result set is moved successfully; returns false otherwise. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. + * @throws {BusinessError} 401 - Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param rowIndex Indicates the index of the specified row, which starts from 0. - * @return Returns true if the result set is moved successfully; returns false otherwise. + * @since 9 */ goToRow(position: number): boolean; @@ -159,10 +470,11 @@ export interface ResultSet { * Go to the first row of the result set. * * @note N/A - * @since 7 + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns true if the result set is moved successfully; - * returns false otherwise, for example, if the result set is empty. + * @since 9 */ goToFirstRow(): boolean; @@ -170,10 +482,11 @@ export interface ResultSet { * Go to the last row of the result set. * * @note N/A - * @since 7 + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is empty. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns true if the result set is moved successfully; - * returns false otherwise, for example, if the result set is empty. + * @since 9 */ goToLastRow(): boolean; @@ -181,10 +494,11 @@ export interface ResultSet { * Go to the next row of the result set. * * @note N/A - * @since 7 + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the last row. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. * @syscap SystemCapability.DistributedDataManager.RelationalStore.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. + * @since 9 */ goToNextRow(): boolean; @@ -192,10 +506,11 @@ export interface ResultSet { * Go to the previous row of the result set. * * @note N/A - * @since 7 + * @returns {boolean} returns true if the result set is moved successfully; + * returns false otherwise, for example, if the result set is already in the first row. + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. * @syscap SystemCapability.DistributedDataManager.RelationalStore.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. + * @since 9 */ goToPreviousRow(): boolean; @@ -204,10 +519,12 @@ export interface ResultSet { * * @note The implementation class determines whether to throw an exception if the value of the specified column * in the current row is null or the specified column is not of the Blob type. - * @since 7 + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {Uint8Array} returns the value of the specified column as a byte array. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401- Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnIndex Indicates the specified column index, which starts from 0. - * @return Returns the value of the specified column as a byte array. + * @since 9 */ getBlob(columnIndex: number): Uint8Array; @@ -216,10 +533,12 @@ export interface ResultSet { * * @note The implementation class determines whether to throw an exception if the value of the specified column * in the current row is null or the specified column is not of the string type. - * @since 7 + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {string} returns the value of the specified column as a string. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnIndex Indicates the specified column index, which starts from 0. - * @return Returns the value of the specified column as a string. + * @since 9 */ getString(columnIndex: number): string; @@ -228,10 +547,12 @@ export interface ResultSet { * * @note The implementation class determines whether to throw an exception if the value of the specified column * in the current row is null, the specified column is not of the integer type. - * @since 7 + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {number} returns the value of the specified column as a long. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnIndex Indicates the specified column index, which starts from 0. - * @return Returns the value of the specified column as a long. + * @since 9 */ getLong(columnIndex: number): number; @@ -240,10 +561,12 @@ export interface ResultSet { * * @note The implementation class determines whether to throw an exception if the value of the specified column * in the current row is null, the specified column is not of the double type. - * @since 7 + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {number} returns the value of the specified column as a double. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnIndex Indicates the specified column index, which starts from 0. - * @return Returns the value of the specified column as a double. + * @since 9 */ getDouble(columnIndex: number): number; @@ -251,11 +574,13 @@ export interface ResultSet { * Checks whether the value of the specified column in the current row is null. * * @note N/A - * @since 7 + * @param {number} columnIndex - Indicates the specified column index, which starts from 0. + * @returns {boolean} returns true if the value of the specified column in the current row is null; + * returns false otherwise. + * @throws {BusinessError} 14800013 - The column value is null or the column type is incompatible. + * @throws {BusinessError} 401 - Parameter error. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @param columnIndex Indicates the specified column index, which starts from 0. - * @return Returns true if the value of the specified column in the current row is null; - * returns false otherwise. + * @since 9 */ isColumnNull(columnIndex: number): boolean; @@ -263,9 +588,9 @@ export interface ResultSet { * Closes the result set. * * @note Calling this method on the result set will release all of its resources and makes it ineffective. - * @since 7 + * @throws {BusinessError} 14800012 - The result set is empty or the specified location is invalid. * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core - * @return Returns true if the result set is closed; returns false otherwise. + * @since 9 */ close(): void; } \ No newline at end of file diff --git a/api/device-define/car.json b/api/device-define/car.json index 4d0c0427b7f0e84ab35178238a579e11f9a6a1b0..d9f3255d0243357b39122f88be6d30020c4caacc 100644 --- a/api/device-define/car.json +++ b/api/device-define/car.json @@ -107,6 +107,7 @@ "SystemCapability.FileManagement.File.DistributedFile", "SystemCapability.FileManagement.AppFileService", "SystemCapability.FileManagement.UserFileService", + "SystemCapability.FileManagement.UserFileManager.Core", "SystemCapability.USB.USBManager", "SystemCapability.Startup.SystemInfo", "SystemCapability.DistributedDataManager.RelationalStore.Core", diff --git a/api/device-define/default.json b/api/device-define/default.json index bd9d537417bf17d0dcce97bc33f2bdbdea111a2c..bc91123441f528f8147943ae29f36739da3dba8a 100644 --- a/api/device-define/default.json +++ b/api/device-define/default.json @@ -134,6 +134,7 @@ "SystemCapability.FileManagement.File.DistributedFile", "SystemCapability.FileManagement.AppFileService", "SystemCapability.FileManagement.UserFileService", + "SystemCapability.FileManagement.UserFileManager.Core", "SystemCapability.USB.USBManager", "SystemCapability.Sensors.Sensor", "SystemCapability.Sensors.MiscDevice", diff --git a/api/device-define/tablet.json b/api/device-define/tablet.json index 495e9fa6bbae0ce9e6c1dcc6b61ed62f94359f0a..73bf456d677c8202ea44be6e34d816306a40c371 100644 --- a/api/device-define/tablet.json +++ b/api/device-define/tablet.json @@ -133,6 +133,7 @@ "SystemCapability.FileManagement.File.DistributedFile", "SystemCapability.FileManagement.AppFileService", "SystemCapability.FileManagement.UserFileService", + "SystemCapability.FileManagement.UserFileManager.Core", "SystemCapability.USB.USBManager", "SystemCapability.Sensors.Sensor", "SystemCapability.Sensors.MiscDevice", diff --git a/api/device-define/tv.json b/api/device-define/tv.json index 4a200b0979333f096e689375f2bdfc9cbec0518c..509d24e0c5a60ea98e4ff022f80c74fa3796a61d 100644 --- a/api/device-define/tv.json +++ b/api/device-define/tv.json @@ -113,6 +113,7 @@ "SystemCapability.FileManagement.File.DistributedFile", "SystemCapability.FileManagement.AppFileService", "SystemCapability.FileManagement.UserFileService", + "SystemCapability.FileManagement.UserFileManager.Core", "SystemCapability.USB.USBManager", "SystemCapability.Startup.SystemInfo", "SystemCapability.DistributedDataManager.RelationalStore.Core", diff --git a/api/device-define/wearable.json b/api/device-define/wearable.json index 7844c45225a7ed3e568c29a26113717d818041a5..8a5d9485498cf2e0335934cb9cfc49a97de05ef6 100644 --- a/api/device-define/wearable.json +++ b/api/device-define/wearable.json @@ -113,6 +113,7 @@ "SystemCapability.FileManagement.File.FileIO", "SystemCapability.FileManagement.File.Environment", "SystemCapability.FileManagement.UserFileService", + "SystemCapability.FileManagement.UserFileManager.Core", "SystemCapability.Sensors.Sensor", "SystemCapability.Sensors.MiscDevice", "SystemCapability.Startup.SystemInfo", diff --git a/api/tag/nfctech.d.ts b/api/tag/nfctech.d.ts index 72c7aa22cc59ff62ae6234d41cd17a18cb81a934..7fa6ba118aed306fcd06620cb47b1a9398c9ce2d 100644 --- a/api/tag/nfctech.d.ts +++ b/api/tag/nfctech.d.ts @@ -148,26 +148,32 @@ export interface NfcVTag extends TagSession { */ export interface IsoDepTag extends TagSession { /** - * Get Historical bytes of the tag. - * @return the Historical bytes. + * Gets IsoDep Historical bytes of the tag, which is based on NfcA RF technology. + * It could be null if not based on NfcA. + * + * @return { number[] } Returns the Historical bytes, the length could be 0. * @since 9 - * @permission ohos.permission.NFC_TAG */ getHistoricalBytes(): number[]; /** - * Get HiLayerResponse bytes of the tag. - * @return HiLayerResponse bytes + * Gets IsoDep HiLayer Response bytes of the tag, which is based on NfcB RF technology. + * It could be null if not based on NfcB. + * + * @return { number[] } Returns HiLayer Response bytes, the length could be 0. * @since 9 - * @permission ohos.permission.NFC_TAG */ getHiLayerResponse(): number[]; /** - * Check if externded apdu length supported or not. - * @return return true if externded apdu length supported, otherwise false. - * @since 9 + * Checks if extended apdu length supported or not. + * + * @return { boolean } Returns true if extended apdu length supported, otherwise false. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ isExtendedApduSupported(): Promise; isExtendedApduSupported(callback: AsyncCallback): void; @@ -175,61 +181,12 @@ export interface IsoDepTag extends TagSession { export interface NdefMessage { /** - * Get all records of a ndef message. - * @return record list of a ndef message + * Obtains all records of an NDEF message. + * + * @return { tag.NdefRecord[] } Records the list of NDEF records. * @since 9 - * @permission ohos.permission.NFC_TAG */ getNdefRecords(): tag.NdefRecord[]; - - /** - * Create a ndef record with uri data. - * @param uri uri data for new a ndef record - * @return the instance of NdefRecord - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - makeUriRecord(uri: string): tag.NdefRecord; - - /** - * Create a ndef record with text data. - * @param text text data for new a ndef record - * @param locale language code for the ndef record. if locale is null, use default locale - * @return the instance of NdefRecord - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - makeTextRecord(text: string, locale: string): tag.NdefRecord; - - /** - * Create a ndef record with mime data. - * @param mimeType type of mime data for new a ndef record - * @param mimeData mime data for new a ndef record - * @return the instance of NdefRecord - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - makeMimeRecord(mimeType: string, mimeData: number[]): tag.NdefRecord; - - /** - * Create a ndef record with external data. - * @param domainName domain name of issuing organization for the external data - * @param serviceName domain specific type of data for the external data - * @param externalData data payload of a ndef record - * @return the instance of NdefRecord - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - makeExternalRecord(domainName: string, serviceName: string, externalData: number[]): tag.NdefRecord; - - /** - * Parse a ndef message into raw bytes. - * @param ndefMessage a ndef message to parse - * @return raw bytes of a ndef message - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - messageToBytes(ndefMessage: NdefMessage): number[]; } /** @@ -240,90 +197,85 @@ export interface NdefMessage { */ export interface NdefTag extends TagSession { /** - * Create a ndef message with raw bytes. - * @param data raw bytes to parse ndef message - * @return the instance of NdefMessage - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - createNdefMessage(data: number[]): NdefMessage; - - /** - * Create a ndef message with record list. - * @param ndefRecords record list to parse ndef message - * @return the instance of NdefMessage - * @since 9 - * @permission ohos.permission.NFC_TAG - */ - createNdefMessage(ndefRecords: tag.NdefRecord[]): NdefMessage; - - /** - * Get the type of the Ndef tag. - * @return type of Ndef tag. + * Gets the type of NDEF tag. + * + * @return { tag.NfcForumType } The type of NDEF tag. * @since 9 - * @permission ohos.permission.NFC_TAG */ getNdefTagType(): tag.NfcForumType; /** - * Get the ndef message that was read from ndef tag when tag discovery. - * @return ndef message. + * Gets the NDEF message that was read from NDEF tag when tag discovery. + * + * @return { NdefMessage } The instance of NdefMessage. * @since 9 - * @permission ohos.permission.NFC_TAG */ getNdefMessage(): NdefMessage; /** - * Check if ndef tag is writable. - * @return return true if the tag is writable, otherwise return false. + * Checks if NDEF tag is writable. + * + * @return { boolean } Returns true if the tag is writable, otherwise returns false. * @since 9 - * @permission ohos.permission.NFC_TAG */ - isNdefWritable(): Promise; - isNdefWritable(callback: AsyncCallback): void; + isNdefWritable(): boolean; /** - * Read ndef message on this tag. - * @return ndef message in tag. - * @since 9 + * Reads NDEF message on this tag. + * + * @return { NdefMessage } The NDEF message in tag. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ readNdef(): Promise; readNdef(callback: AsyncCallback): void; /** - * Write ndef message into this tag. - * @param msg ndef message to write - * @return Error code of write. if return 0, means successful. - * @since 9 + * Writes NDEF message into this tag. + * + * @param { NdefMessage } msg - The NDEF message to be written. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - writeNdef(msg: NdefMessage): Promise; - writeNdef(msg: NdefMessage, callback: AsyncCallback): void; + writeNdef(msg: NdefMessage): Promise; + writeNdef(msg: NdefMessage, callback: AsyncCallback): void; /** - * Check ndef tag can be set read-only - * @return return true if the tag can be set readonly, otherwise return false. - * @since 9 + * Checks NDEF tag can be set read-only. + * + * @return { boolean } Returns true if the tag can be set readonly, otherwise returns false. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ canSetReadOnly(): boolean; /** - * Set ndef tag read-only - * @return if return 0 means successful, otherwise the error code. - * @since 9 + * Sets the NDEF tag read-only. + * * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - setReadOnly(): Promise; - setReadOnly(callback: AsyncCallback): void; + setReadOnly(): Promise; + setReadOnly(callback: AsyncCallback): void; /** - * Convert the Nfc forum type into byte array defined in Nfc forum. - * @param type Nfc forum type of ndef tag - * @return Nfc forum type byte array + * Converts the NFC forum type into string defined in NFC forum. + * + * @param { tag.NfcForumType } type - NFC forum type of NDEF tag. + * @return { string } The NFC forum string type. + * @throws { BusinessError } 401 - The parameter check failed. * @since 9 - * @permission ohos.permission.NFC_TAG */ getNdefTagTypeString(type: tag.NfcForumType): string; } @@ -336,136 +288,161 @@ export interface NdefTag extends TagSession { */ export interface MifareClassicTag extends TagSession { /** - * Authenticate a sector with the key.Only successful authentication sector can be operated. - * @param sectorIndex Index of sector to authenticate - * @param key key(6-bytes) to authenticate - * @param isKeyA KeyA flag. true means KeyA, otherwise KeyB - * @return Result of authenticattion. if return ture, means successful. - * @since 9 + * Authenticates a sector with the key.Only successful authentication sector can be operated. + * + * @param { number } sectorIndex - Index of sector to authenticate. + * @param { number[] } key - The key(6-bytes) to authenticate. + * @param { boolean } isKeyA - KeyA flag. true means KeyA, otherwise KeyB. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise; - authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback): void; + authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise; + authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback): void; /** - * Read a block, one block size is 16 bytes. - * @param blockIndex index of block to read - * @return the block data - * @since 9 + * Reads a block, one block size is 16 bytes. + * + * @param { number } blockIndex - The index of block to read. + * @return { number[] } Returns the block data. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ readSingleBlock(blockIndex: number): Promise; readSingleBlock(blockIndex: number, callback: AsyncCallback): void; /** - * Write a block, one block size is 16 bytes. - * @param blockIndex index of block to write - * @param data block data to write - * @return Error code of write. if return 0, means successful. + * Writes a block, one block size is 16 bytes. + * + * @param { number } blockIndex - The index of block to write. + * @param { number } data - The block data to write. + * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 - * @permission ohos.pemission.NFC_TAG */ - writeSingleBlock(blockIndex: number, data: number[]): Promise; - writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback): void; + writeSingleBlock(blockIndex: number, data: number[]): Promise; + writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback): void; /** - * Increment a value block - * @param blockIndex index of block to increment - * @param value value to increment, none-negative - * @return Error code of increment. if return 0, means successful. - * @since 9 + * Increments the contents of a block, and stores the result in the internal transfer buffer. + * + * @param { number } blockIndex - The index of block to increment. + * @param { number } value - The value to increment, none-negative. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - incrementBlock(blockIndex: number, value: number): Promise; - incrementBlock(blockIndex: number, value: number, callback: AsyncCallback): void; + incrementBlock(blockIndex: number, value: number): Promise; + incrementBlock(blockIndex: number, value: number, callback: AsyncCallback): void; /** - * Decrement a value block - * @param blockIndex index of block to decrement - * @param value value to increment, none-negative - * @return Error code of decrement. if return 0, means successful. - * @since 9 + * Decrements the contents of a block, and stores the result in the internal transfer buffer. + * + * @param { number } blockIndex - The index of block to decrement. + * @param { number } value - The value to decrement, none-negative. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - decrementBlock(blockIndex: number, value: number): Promise; - decrementBlock(blockIndex: number, value: number, callback: AsyncCallback): void; + decrementBlock(blockIndex: number, value: number): Promise; + decrementBlock(blockIndex: number, value: number, callback: AsyncCallback): void; /** - * Copy from the value of register to the value block - * @param blockIndex index of value block to copy to - * @return if return 0, means successful. otherwise the error code - * @since 9 + * Writes the contents of the internal transfer buffer to a value block. + * + * @param { number } blockIndex - The index of value block to be written. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - transferToBlock(blockIndex: number): Promise; - transferToBlock(blockIndex: number, callback: AsyncCallback): void; + transferToBlock(blockIndex: number): Promise; + transferToBlock(blockIndex: number, callback: AsyncCallback): void; /** - * Copy from the value block to the register - * @param blockIndex index of value block to copy from - * @return if return 0, means successful. otherwise the error code - * @since 9 + * Moves the contents of a block into the internal transfer buffer. + * + * @param { number } blockIndex - The index of value block to be moved from. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - restoreFromBlock(blockIndex: number): Promise; - restoreFromBlock(blockIndex: number, callback: AsyncCallback): void; + restoreFromBlock(blockIndex: number): Promise; + restoreFromBlock(blockIndex: number, callback: AsyncCallback): void; /** - * Get the number of sectors in mifareclassic tag - * @return the number of sectors. + * Gets the number of sectors in MifareClassic tag. + * + * @return { number } Returns the number of sectors. * @since 9 - * @permission ohos.permission.NFC_TAG */ getSectorCount(): number; /** - * Get the number of blocks in the sector. - * @param sectorIndex index of sector - * @return the number of blocks. + * Gets the number of blocks in the sector. + * + * @param { number } sectorIndex - The index of sector. + * @return { number } Returns the number of blocks. + * @throws { BusinessError } 401 - The parameter check failed. * @since 9 - * @permission ohos.permission.NFC_TAG */ getBlockCountInSector(sectorIndex: number): number; /** - * Get the type of the MifareClassic tag. - * @return type of MifareClassic tag. + * Gets the type of the MifareClassic tag. + * + * @return { tag.MifareClassicType } Returns type of MifareClassic tag. * @since 9 - * @permission ohos.permission.NFC_TAG */ getType(): tag.MifareClassicType; /** - * Get size of the tag in bytes, see {@code MifareTagSize}. - * @return size of the tag + * Gets size of the tag in bytes. + * + * @return { number } Returns the size of the tag. * @since 9 - * @permission ohos.permission.NFC_TAG */ getTagSize(): number; /** - * check if if tag is emulated - * @return return true if tag is emulated, otherwise return false. + * Checks if the tag is emulated or not. + * + * @return { boolean } Returns true if tag is emulated, otherwise false. * @since 9 - * @permission ohos.permission.NFC_TAG */ isEmulatedTag(): boolean; /** - * Get the first block of the specific sector. - * @param sectorIndex index of sector - * @return index of first block in the sector + * Gets the first block of the specific sector. + * + * @param { number } sectorIndex - The index of sector. + * @return { number } Returns index of first block in the sector. + * @throws { BusinessError } 401 - The parameter check failed. * @since 9 - * @permission ohos.permission.NFC_TAG */ getBlockIndex(sectorIndex: number): number; /** - * Get the sector index, that the sector contains the specific block. - * @param blockIndex index of block - * @return the sector index + * Gets the sector index, that the sector contains the specific block. + * + * @param { number } blockIndex - The index of block. + * @return { number } Returns the sector index. + * @throws { BusinessError } 401 - The parameter check failed. * @since 9 - * @permission ohos.permission.NFC_TAG */ getSectorIndex(blockIndex: number): number; } @@ -478,31 +455,38 @@ export interface MifareClassicTag extends TagSession { */ export interface MifareUltralightTag extends TagSession { /** - * Read 4 pages, total is 16 bytes. page size is 4bytes. - * @param pageIndex index of page to read - * @return 4 pages data - * @since 9 + * Reads 4 pages, total is 16 bytes. Page size is 4 bytes. + * + * @param { number } pageIndex - The index of page to read. + * @return { number[] } Returns 4 pages data. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ readMultiplePages(pageIndex: number): Promise; readMultiplePages(pageIndex: number, callback: AsyncCallback): void; /** - * Write a page, total 4 bytes. - * @param pageIndex index of page to write - * @param data page data to write - * @return Error code of write. if return 0, means successful. - * @since 9 + * Writes a page, total 4 bytes. + * + * @param { number } pageIndex - The index of page to write. + * @param { number[] } data - The page data to write. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - writeSinglePages(pageIndex: number, data: number[]): Promise; - writeSinglePages(pageIndex: number, data: number[], callback: AsyncCallback): void; + writeSinglePage(pageIndex: number, data: number[]): Promise; + writeSinglePage(pageIndex: number, data: number[], callback: AsyncCallback): void; /** - * Get the type of the MifareUltralight tag in bytes. - * @return type of MifareUltralight tag. + * Gets the type of the MifareUltralight tag. + * + * @return { tag.MifareUltralightType } Returns the type of MifareUltralight tag. * @since 9 - * @permission ohos.permission.NFC_TAG */ getType(): tag.MifareUltralightType; } @@ -515,22 +499,28 @@ export interface MifareUltralightTag extends TagSession { */ export interface NdefFormatableTag extends TagSession { /** - * Format a tag as NDEF tag, then write Ndef message into the Ndef Tag - * @param message Ndef message to write while format successful. it can be null, then only format the tag. - * @return if return 0, means successful. otherwise the error code - * @since 9 + * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag. + * + * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - format(message: NdefMessage): Promise; - format(message: NdefMessage, callback: AsyncCallback): void; + format(message: NdefMessage): Promise; + format(message: NdefMessage, callback: AsyncCallback): void; /** - * Format a tag as NDEF tag, then write Ndef message into the Ndef Tag, then set the tag readonly - * @param message Ndef message to write while format successful. it can be null, then only format the tag. - * @return if return 0, means successful. otherwise the error code - * @since 9 + * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag, then sets the tag readonly. + * + * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag. * @permission ohos.permission.NFC_TAG + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 401 - The parameter check failed. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. + * @since 9 */ - formatReadOnly(message: NdefMessage): Promise; - formatReadOnly(message: NdefMessage, callback: AsyncCallback): void; + formatReadOnly(message: NdefMessage): Promise; + formatReadOnly(message: NdefMessage, callback: AsyncCallback): void; } \ No newline at end of file diff --git a/build-tools/.gitignore b/build-tools/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..788432e1970568d4104eed1ed8026e0a962cdb98 --- /dev/null +++ b/build-tools/.gitignore @@ -0,0 +1,5 @@ +**/node_modules/** +**/package-lock.json +**/.editorconfig +**/.prettierrc +api/ diff --git a/build-tools/api_check_plugin/code_style_rule.json b/build-tools/api_check_plugin/code_style_rule.json index c0e992d06a7e7f825ab503b368993eb755ec8757..a638432928d66a4f36471c56ac2d07a042b212a0 100644 --- a/build-tools/api_check_plugin/code_style_rule.json +++ b/build-tools/api_check_plugin/code_style_rule.json @@ -439,7 +439,8 @@ "File.Environment", "File.DistributedFile", "AppFileService", - "UserFileService" + "UserFileService", + "UserFileManager" ], "USB":[ "USBManager" diff --git a/build-tools/api_check_plugin/entry.js b/build-tools/api_check_plugin/entry.js index 849416c805b4ec84730b5bd581f4f3902542a718..95bf7557e3ea0775c2866a480173d50371e7c3a1 100644 --- a/build-tools/api_check_plugin/entry.js +++ b/build-tools/api_check_plugin/entry.js @@ -14,23 +14,26 @@ */ const path = require("path"); +const fs = require("fs"); const { writeResultFile } = require('./src/utils'); function checkEntry(url) { - let result = "API CHECK FAILED!"; + let result = ""; + const sourceDirname = __dirname; __dirname = "interface/sdk-js/build-tools/api_check_plugin"; + const mdFilesPath = path.resolve(sourceDirname, '../../../../', "all_files.txt"); + const content = fs.readFileSync(mdFilesPath, "utf-8"); try { const execSync = require("child_process").execSync; execSync("cd interface/sdk-js/build-tools/api_check_plugin && npm install"); const { scanEntry } = require(path.resolve(__dirname, "./src/api_check_plugin")); - result = scanEntry(url); - const content = fs.readFileSync(path.resolve(__dirname, "./Result.txt"), "utf-8"); - result += `mdFilePath = ${url}, content = ${content}` + result += scanEntry(mdFilesPath); + result += `,,,mdFilePath = ${mdFilesPath}, content = ${content}`; const { removeDir } = require(path.resolve(__dirname, "./src/utils")); removeDir(path.resolve(__dirname, "node_modules")); } catch (error) { // catch error - result = `CATCHERROR : ${error}`; + result += `CATCHERROR : ${error}, mdFilePath = ${mdFilesPath}, content = ${content}`; } writeResultFile(result, path.resolve(__dirname, "./Result.txt"), {}); } diff --git a/build-tools/api_check_plugin/plugin/scan_entry.py b/build-tools/api_check_plugin/plugin/scan_entry.py deleted file mode 100644 index bf1530c1f5eda4784ca3a93692dad220e496f141..0000000000000000000000000000000000000000 --- a/build-tools/api_check_plugin/plugin/scan_entry.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# 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 os -import shutil -import execjs - -def run_scan(path): - result = [] - rootDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(_file_)))) - entryDir = os.path.join(rootDir, "interface/sdk-js/build-tools/api_check_plugin/entry.js").replace("\\","/") - resultDir = os.path.join(rootDir, "interface/sdk-js/build-tools/api_check_plugin/Result.txt").replace("\\","/") - cmdDir = "node" + entryDir + " " + os.path.join(rootDir,path) - subprocess.check_output(cmdDir, shell=True) - file_object = open(resultDir,"r") - try: - result = file_object.read() - finally: - file_object.close() - - os.remove(os.path.abspath(resultDir)) - return True,result - -def js_from_file(file_name): - with open(file_name, "r", encoding="UTF-8") as file: - result = file.read() - return result - -if __name__ == "__main__": - run_scan("ci-tools/ci-build/mdFiles.txt") diff --git a/build-tools/api_check_plugin/src/api_check_plugin.js b/build-tools/api_check_plugin/src/api_check_plugin.js index 43420ddf3770ca1f6b9fdee19d477ce568a0d968..35328140ea5cd8a4684592bd2a87c64fc44957ee 100644 --- a/build-tools/api_check_plugin/src/api_check_plugin.js +++ b/build-tools/api_check_plugin/src/api_check_plugin.js @@ -34,7 +34,7 @@ function checkAPICodeStyle(url) { function getMdFiles(url) { const content = fs.readFileSync(url, "utf-8"); - const mdFiles = content.split("\r\n"); + const mdFiles = content.split(/[(\r\n)\r\n]+/); return mdFiles; } diff --git a/build-tools/collect_application_api/README_EN.md b/build-tools/collect_application_api/README_EN.md deleted file mode 100644 index da16a6f70e10f05a4ffb921cf84fb6076c77cd28..0000000000000000000000000000000000000000 --- a/build-tools/collect_application_api/README_EN.md +++ /dev/null @@ -1,16 +0,0 @@ -COLLECT_APPLICATION_API - -Usage -1.Install - Install the npm dependencies(You must have node&npm installed): - $npm install - -2.Quick Start - In the src directory - $node format - -3.Directory Structure - ./sdk--- directory path of API files - ./application--- directory path of application - ./deps--- directory path of source code - ./src--- directory path of result \ No newline at end of file diff --git a/build-tools/collect_application_api/README_zh.md b/build-tools/collect_application_api/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..ec7e2df2a41813371fb8c59060f370f7d81c6404 --- /dev/null +++ b/build-tools/collect_application_api/README_zh.md @@ -0,0 +1,36 @@ +# 应用API解析工具 + +## 简介 + +该工具可用于解析应用中使用的API,并汇总成表格,提供给应用开发者 + +## 目录 + +``` +├─sdk #存放API文件的目录(sdk中,ets目录下的api文件夹和build-tools文件夹) +├─application #存放被解析的应用源码 +├─deps #存放typescript源码 +└─src #存放源码以及生成的表格 +``` + +## 使用方法 + +### 目录配置 + +新建sdk文件夹,放置api文件; + +新建application文件夹,放置被解析的应用源码; + +新建deps文件夹,放置[typescript源码](https://gitee.com/openharmony/third_party_typescript/tree/master/build_package)。 + +### 安装 + +需要安装npm依赖环境:$npm install。 + +### 使用工具 + +进入src目录下:$node format。 + +## 相关文件夹 + +[collect_application_api](https://gitee.com/openharmony/interface_sdk-js/tree/master/build-tools/collect_application_api) \ No newline at end of file diff --git a/build-tools/delete_systemapi_plugin.js b/build-tools/delete_systemapi_plugin.js index db69d1a5f1dd102aa38ad6ff667c6cca3a76ebc4..ac7a6d30ea208bd09503243753cec8b43ba50eff 100644 --- a/build-tools/delete_systemapi_plugin.js +++ b/build-tools/delete_systemapi_plugin.js @@ -129,6 +129,9 @@ function formatImportDeclaration(url) { const clauseNode = statement.importClause; if (!clauseNode.namedBindings && clauseNode.name && ts.isIdentifier(clauseNode.name)) { clauseSet.add(clauseNode.name.escapedText.toString()); + } else if (clauseNode.namedBindings && clauseNode.namedBindings.name && + ts.isIdentifier(clauseNode.namedBindings.name)) { + clauseSet.add(clauseNode.namedBindings.name.escapedText.toString()); } else if (clauseNode.namedBindings && clauseNode.namedBindings.elements) { clauseNode.namedBindings.elements.forEach(ele => { if (ele.name && ts.isIdentifier(ele.name)) { @@ -277,7 +280,9 @@ function deleteSystemApi(url) { exports.deleteSystemApi = deleteSystemApi; function isSystemapi(node) { - const notesStr = node.getFullText().replace(node.getText(), "").replace(/[\s]/g, ""); + const notesContent = node.getFullText().replace(node.getText(), "").replace(/[\s]/g, ""); + const notesArr = notesContent.split(/\/\*\*/); + const notesStr = notesArr[notesArr.length - 1]; if (notesStr.length !== 0) { if (ts.isFunctionDeclaration(node) || ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) { lastNodeName = node.name && node.name.escapedText ? node.name.escapedText.toString() : ""; diff --git a/build-tools/permissions_converter/.vscode/settings.json b/build-tools/permissions_converter/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..51dc9242112d062632635868b503ec3dcfa674c5 --- /dev/null +++ b/build-tools/permissions_converter/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.suggest.snippetsPreventQuickSuggestions": false +} diff --git a/build-tools/permissions_converter/convert.js b/build-tools/permissions_converter/convert.js new file mode 100644 index 0000000000000000000000000000000000000000..3c54fb7e7d3a0e8d5db5a154a1ad66c8ce8913dc --- /dev/null +++ b/build-tools/permissions_converter/convert.js @@ -0,0 +1,111 @@ +/* + * 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. + */ + +const fs = require('fs'); + +const copyRight = `/* + * 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. + */\n\n`; +const typeHead = 'export type Permissions =\n'; +const typeTail = ';'; +const tab = ' '; +const tabs = tab.repeat(2); +const tabzz = tab.repeat(3); +const commentHead = `${tabs}/**\n`; +const commentBody = `${tabzz}* `; +const commentTail = `${tabzz}*/\n`; +const sinceTag = '@since '; +const deprecatedTag = '@deprecated '; +const orOperator = `${tabs}|${tab}`; + +const getPermissions = downloadPath => { + try { + const content = fs.readFileSync(downloadPath, { encoding: 'utf8' }); + const configMap = JSON.parse(decodeURIComponent(content)); + if (configMap.module.definePermissions) { + return configMap.module.definePermissions; + } + } catch (error) { + console.error('Convert json file to object failed'); + } + return undefined; +}; + +const convertJsonToDTS = (permissions, outputFilePath) => { + if (fs.existsSync(outputFilePath)) { + fs.unlinkSync(outputFilePath); + } + fs.appendFileSync(outputFilePath, copyRight, 'utf8'); + fs.appendFileSync(outputFilePath, typeHead, 'utf8'); + permissions.forEach((permission, index) => { + if (permission.since || permission.deprecated) { + fs.appendFileSync(outputFilePath, commentHead, 'utf8'); + if (permission.since) { + const since = `${commentBody}${sinceTag}${permission.since}\n`; + fs.appendFileSync(outputFilePath, since, 'utf8'); + } + if (permission.deprecated) { + const deprecated = `${commentBody}${deprecatedTag}${permission.deprecated}\n`; + fs.appendFileSync(outputFilePath, deprecated, 'utf8'); + } + fs.appendFileSync(outputFilePath, commentTail, 'utf8'); + } + const permissionName = `${index === 0 ? tabs : orOperator}'${permission.name}'${ + index === permissions.length - 1 ? '' : '\n' + }`; + fs.appendFileSync(outputFilePath, permissionName, 'utf8'); + }); + fs.appendFileSync(outputFilePath, typeTail, 'utf8'); + console.log('Convert config.json definePermissions to permissions.d.ts successfully'); +}; + +/** + * Read config.json file and convert it to permission.d.ts + * + * @param { + * filePath: name of downloaded config.json file + * outputFileName: name of converted d.ts file name + * } options + */ +const convert = options => { + const permissions = getPermissions(options.filePath); + if (permissions) { + convertJsonToDTS(permissions, options.outputFilePath); + } else { + console.error('Config file does not have definePermissions property'); + } +}; + +const arguments = process.argv; +const options = { + filePath: arguments[2], + outputFilePath: arguments[3], +}; +try { + convert(options); +} catch (error) { + console.error(`ERROR FOR CONVERTING PERMISSION: ${error}`); +} diff --git a/build-tools/permissions_converter/package.json b/build-tools/permissions_converter/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a0dec26bd57461d1ace84f44986273b599cae801 --- /dev/null +++ b/build-tools/permissions_converter/package.json @@ -0,0 +1,6 @@ +{ + "name": "permissions", + "version": "1.0.0", + "description": "", + "main": "./convert.js" +}