From d67633337808b326051a27dada05c802a1b8bb30 Mon Sep 17 00:00:00 2001 From: li-bo-boblove Date: Fri, 5 Aug 2022 15:01:36 +0800 Subject: [PATCH] add msdp js api Signed-off-by:li-bo-boblove Signed-off-by: li-bo-boblove --- api/@ohos.devicestatus.d.ts | 219 +++++++++----------------------- api/@ohos.geofence.d.ts | 177 ++++++++++++++++++++++++++ api/@ohos.motion.d.ts | 190 ++------------------------- api/@ohos.movement.d.ts | 200 ++++++++--------------------- api/@ohos.spatialAwareness.d.ts | 180 +++++++++++--------------- api/@ohos.timeline.d.ts | 165 ++++++++++++++++++++++++ 6 files changed, 549 insertions(+), 582 deletions(-) create mode 100644 api/@ohos.geofence.d.ts create mode 100644 api/@ohos.timeline.d.ts diff --git a/api/@ohos.devicestatus.d.ts b/api/@ohos.devicestatus.d.ts index a9c792eb20..c1ca86088d 100644 --- a/api/@ohos.devicestatus.d.ts +++ b/api/@ohos.devicestatus.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,200 +13,107 @@ * limitations under the License. */ -import { AsyncCallback } from "./basic"; +import { Callback } from "./basic"; /** - * Subscribe to user device status notifications + * 订阅设备状态,可上报静止状态、相对静止状态等事件。 * * @since 9 * @syscap SystemCapability.Msdp.DeviceStatus - * @import import sensor from '@ohos.DeviceStatus' - * @permission N/A + * @import import DeviceStatus from '@ohos.DeviceStatus' */ -declare namespace DeviceStatus { +declare namespace deviceStatus { /** - * Behavior-aware data。 + * 设备状态。 + * * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 */ - export interface ActivityResponse { - eventType: EventType + interface ActivityResponse { + state: ActivityState; } /** - * Absolutely static data。 - * @syscap SystemCapability.Msdp.DeviceStatus - */ - export interface StillResponse extends ActivityResponse {} - - /** - * Relatively static data。 - * @syscap SystemCapability.Msdp.DeviceStatus - */ - export interface RelativeStillResponse extends ActivityResponse {} - - /** - * Vertically positioned data。 - * @syscap SystemCapability.Msdp.DeviceStatus - */ - export interface VerticalPositionResponse extends ActivityResponse {} - - /** - * Horizontal position of the data。 - * @syscap SystemCapability.Msdp.DeviceStatus - */ - export interface HorizontalPositionResponse extends ActivityResponse {} - - /** - * Behavior recognition type。 + * 设备状态类型。 + * * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 */ - export enum ActivityType { - TYPE_STILL = "still", - TYPE_RELATIVE_STILL = "relativeStill", - TYPE_VERTICAL_POSITION = "verticalPosition", - TYPE_HORIZONTAL_POSITION = "horizontalPosition" - } + type ActivityType = 'still' | 'relativeStill'; /** - * The event type。 + * 设备状态事件。 + * * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 */ - export enum EventType { + enum ActivityEvent { + /** + * 进入设备状态。 + */ ENTER = 1, + + /** + * 退出设备状态。 + */ EXIT = 2, + + /** + * 进入和退出设备状态。 + */ ENTER_EXIT = 3 } - - /** - * Subscriptions are absolutely static。 - * - * @since 9 - * @param type Subscriptions are absolutely static, {@code type: ActivityType.TYPE_STILL}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: ActivityType.TYPE_STILL, eventType: EventType, reportLatencyNs: number, callback: AsyncCallback): void; /** - * Subscriptions are relatively static。 - * - * @since 9 - * @param type Subscriptions are relatively static, {@code type: ActivityType.TYPE_RELATIVE_STILL}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: ActivityType.TYPE_RELATIVE_STILL, eventType: EventType, reportLatencyNs: number, callback: AsyncCallback): void; - - /** - * Subscribe to the vertical position。 - * - * @since 9 - * @param type Subscribe to the vertical position, {@code type: ActivityType.TYPE_VERTICAL_POSITION}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: ActivityType.TYPE_VERTICAL_POSITION, eventType: EventType, reportLatencyNs: number, callback: AsyncCallback): void; - - /** - * Subscribe to horizontal locations。 - * - * @since 9 - * @param type Subscribe to horizontal locations, {@code type: ActivityType.TYPE_HORIZONTAL_POSITION}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: ActivityType.TYPE_HORIZONTAL_POSITION, eventType: EventType, reportLatencyNs: number, callback: AsyncCallback): void; - - /** - * Query whether it is absolutely static。 - * - * @since 9 - * @param type Query whether it is absolutely static, {@code type: ActivityType.TYPE_STILL}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function once(type: ActivityType.TYPE_STILL, callback: AsyncCallback): void; - - /** - * Query whether it is relatively stationary。 + * 设备状态。 * + * @syscap SystemCapability.Msdp.DeviceStatus * @since 9 - * @param type Query whether it is relatively stationary, {@code type: ActivityType.TYPE_RELATIVE_STILL}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. */ - function once(type: ActivityType.TYPE_RELATIVE_STILL, callback: AsyncCallback): void; - - /** - * Query whether the vertical position is。 + enum ActivityState { + /** + * 进入设备状态。 + */ + ENTER = 1, + + /** + * 退出设备状态。 + */ + EXIT = 2 + } + + /** + * 订阅设备状态。 * + * @param activity 设备状态类型,{@code type: ActivityType}。 + * @param event 设备状态事件。 + * @param reportLatencyNs 事件上报周期。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.DeviceStatus * @since 9 - * @param type Query whether the vertical position is, {@code type: ActivityType.TYPE_VERTICAL_POSITION}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. */ - function once(type: ActivityType.TYPE_VERTICAL_POSITION, callback: AsyncCallback): void; + function on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback): void; /** - * Query whether the horizontal position is。 + * 查询设备状态。 * + * @param activity 设备状态类型,{@code type: ActivityType}。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.DeviceStatus * @since 9 - * @param type Query whether the horizontal position is, {@code type: ActivityType.TYPE_HORIZONTAL_POSITION}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. */ - function once(type: ActivityType.TYPE_HORIZONTAL_POSITION, callback: AsyncCallback): void; + function once(activity: ActivityType, callback: Callback): void; /** - * Unsubscribe absolutely static。 - * - * @since 9 - * @param type Unsubscribe absolutely static, {@code type: ActivityType.TYPE_STILL}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function off(type: ActivityType.TYPE_STILL, eventType: EventType, callback?: AsyncCallback): void; - - /** - * Unsubscribe is relatively static。 - * - * @since 9 - * @param type Unsubscribe is relatively static, {@code type: ActivityType.TYPE_RELATIVE_STILL}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function off(type: ActivityType.TYPE_RELATIVE_STILL, eventType: EventType, callback?: AsyncCallback): void; - - /** - * Unsubscribe from the vertical location。 - * - * @since 9 - * @param type Unsubscribe from the vertical location, {@code type: ActivityType.TYPE_VERTICAL_POSITION}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function off(type: ActivityType.TYPE_VERTICAL_POSITION, eventType: EventType, callback?: AsyncCallback): void; - - /** - * Unsubscribe from horizontal locations。 + * 取消订阅设备状态。 * + * @param activity 设备状态类型,{@code type: ActivityType}。 + * @param event 设备状态事件。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.DeviceStatus * @since 9 - * @param type Unsubscribe from horizontal locations, {@code type: ActivityType.TYPE_HORIZONTAL_POSITION}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. */ - function off(type: ActivityType.TYPE_HORIZONTAL_POSITION, eventType: EventType, callback?: AsyncCallback): void; + function off(activity: ActivityType, event: ActivityEvent, callback?: Callback): void; } + export default DeviceStatus; \ No newline at end of file diff --git a/api/@ohos.geofence.d.ts b/api/@ohos.geofence.d.ts new file mode 100644 index 0000000000..a388f0e71c --- /dev/null +++ b/api/@ohos.geofence.d.ts @@ -0,0 +1,177 @@ +/* + * 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"; + +/** + * 提供地理围栏数据上报功能,可上报进入景区、离开景区事件。 + * + * @since 9 + * @syscap SystemCapability.Msdp.Geofence + * @import import geofence from '@ohos.geofense' + */ +declare namespace geofence { + /** + * 用于接收地理围栏状态。 + * + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + interface GeofenceResponse { + status: GeofenceState; + } + + /** + * 圆形围栏的选项。 + * + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + interface CircleOption { + /** + * 圆形围栏中心点的坐标。 + */ + centerCoordinate: Array; + + /** + * 圆形围栏半径。 + */ + radius: number; + } + + /** + * 多边形围栏的选项。 + * + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + interface PolygonOption { + /** + * 多边形围栏关键字。 + */ + keyword: string; + + /** + * 多边形围栏类型。 + */ + type: string; + + /** + * 多边形围栏所在的城市。 + */ + city: string; + } + + /** + * 地理围栏的类型。 + * + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + enum GeofenceType{ + /** + * 圆形围栏。 + */ + CIRCLE_FENCE = "CircleFence", + + /** + * 多边形围栏。 + */ + POLYGON_FENCE = "PolygonFence" + } + + /** + * 围栏状态。 + * + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + enum GeofenceState { + /** + * 围栏外。 + */ + OUTSIDE = 1, + + /** + * 围栏内。 + */ + INSIDE = 2, + + /** + * 进入围栏。 + */ + ENTER = 3, + + /** + * 离开围栏。 + */ + EXIT = 4 + } + + /** + * 订阅圆形围栏。 + * + * @param type 围栏类型,{@code GeofenceType}。 + * @param option 围栏的参数选项,{@code Option}。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + function on(type: GeofenceType, option: CircleOption, callback: Callback): void; + + /** + * 订阅多边形围栏。 + * + * @param type 围栏类型,{@code GeofenceType}。 + * @param option 围栏的参数选项,{@code Option}。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + function on(type: GeofenceType, option: PolygonOption, callback: Callback): void; + + /** + * 取消订阅圆形围栏。 + * + * @param type 围栏类型,{@code GeofenceType}。 + * @param option 围栏的可选参数,{@code Option}。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + function off(type: GeofenceType, option: CircleOption, callback?: Callback): void; + + /** + * 取消订阅多边形围栏。 + * + * @param type 围栏类型,{@code GeofenceType}。 + * @param option 围栏的可选参数,{@code Option}。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + function off(type: GeofenceType, option: PolygonOption, callback?: Callback): void; + + /** + * 设置防呆策略的时长。 + * + * @param minuteTime 防呆策略的时长,取值范围大于或等于0。 + * @syscap SystemCapability.Msdp.Geofence + * @since 9 + */ + function setFoolProofTime(inuteTime: number): void; +} + +export default geofence; \ No newline at end of file diff --git a/api/@ohos.motion.d.ts b/api/@ohos.motion.d.ts index abd85d4cfc..0aa4071432 100644 --- a/api/@ohos.motion.d.ts +++ b/api/@ohos.motion.d.ts @@ -16,199 +16,37 @@ import { Callback } from "./basic"; /** - * Provides the ability to subscribe to gesture state. + * 提供手势状态上报功能,可上报拿起、翻转、接近等事件。 * * @since 9 * @sysCap SystemCapability.Sensors.Motion - * @devices phone, tablet - * @import import sensor from '@ohos.motion' - * @permission N/A + * @import import motion from '@ohos.motion' */ declare namespace motion { /** - * The basic data structure of gesture state events。 - * @devices phone, tablet + * 手势状态类型。 * @sysCap SystemCapability.Msdp.Motion - */ - export interface MotionResponse { - motionValue: boolean - } - - /** - * Pick up the data for the event。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface PickupResponse extends MotionResponse {} - - /** - * Roll over the data for the event。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface FlipResponse extends MotionResponse {} - - /** - * Data close to ear events。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface CloseToEarResponse extends MotionResponse {} - - /** - * Shake the data of the event。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface ShakeResponse extends MotionResponse {} - - /** - * Rotate the data for the event。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface RotateResponse extends MotionResponse {} - - /** - * Two-finger swipe event data。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface TwoFingersPinchResponse extends MotionResponse {} - - /** - * Three fingers swipe the data of the event。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export interface ThreeFingersSlideResponse extends MotionResponse {} - - /** - * Gesture state type。 - * @devices phone, tablet - * @sysCap SystemCapability.Msdp.Motion - */ - export enum MotionType { - TYPE_PICKUP = "pickUp", - TYPE_CLOSE_TO_EAR = "closeToEar", - TYPE_FLIP = "flip", - TYPE_SHAKE = "shake", - TYPE_ROTATE = "rotate", - TYPE_TWO_FINGER_PINCH = "twoFingerPinch", - TYPE_THREE_FINGERS_SLIDE = "threeFingersSlide", - } - - /** - * Subscribe to pick up gestures。 - * @param The type of gesture state that subscribes to, {@code type: MotionType.TYPE_PICKUP}. - * @param callback The Callback function that the user subscribes to. - * @since 9 - */ - function on(type: MotionType.TYPE_PICKUP, callback: Callback): void; - - /** - * Subscribe to the near ear gesture。 - * @param Subscribe to the gesture status type, {@code type: MotionType.TYPE_CLOSE_TO_EAR}. - * @param callback The Callback function that the user subscribes to. * @since 9 */ - function on(type: MotionType.TYPE_CLOSE_TO_EAR, callback: Callback): void; - - /** - * Subscribe to the flip event gesture。 - * @param Subscribe to the gesture status type, {@code type: MotionType.TYPE_FLIP}. - * @param callback The Callback function that the user subscribes to. - * @since 9 - */ - function on(type: MotionType.TYPE_FLIP, callback: Callback): void; - - /** - * Subscribe to a shake gesture。 - * @param Subscribe to the gesture status type, {@code type: MotionType.TYPE_SHAKE}. - * @param callback The Callback function that the user subscribes to. - * @since 9 - */ - function on(type: MotionType.TYPE_SHAKE, callback: Callback): void; - - /** - * Subscribe to the rotate gesture。 - * @param Subscribe to the gesture status type, {@code type: MotionType.TYPE_ROTATE}. - * @param callback The Callback function that the user subscribes to. - * @since 9 - */ - function on(type: MotionType.TYPE_ROTATE, callback: Callback): void; - - /** - * Subscribe to two-finger event gestures。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_TWO_FINGER_PINCH}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function on(type: MotionType.TYPE_TWO_FINGER_PINCH, callback?: Callback): void; - - /** - * Subscribe to three-finger event gestures。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_THREE_FINGERS_SLIDE}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function on(type: MotionType.TYPE_THREE_FINGERS_SLIDE, callback?: Callback): void; - - /** - * Cancel the pick-up gesture。 - * @param 取消手势状态的类型, {@code type: MotionType.TYPE_PICKUP}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function off(type: MotionType.TYPE_PICKUP, callback?: Callback): void; - - /** - * Cancel the close gesture。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_CLOSE_TO_EAR}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function off(type: MotionType.TYPE_CLOSE_TO_EAR, callback?: Callback): void; - - /** - * Cancels the flip event gesture。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_FLIP}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function off(type: MotionType.TYPE_FLIP, callback?: Callback): void; - - /** - * Cancel the shake gesture。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_SHAKE}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function off(type: MotionType.TYPE_SHAKE, callback?: Callback): void; - - /** - * Cancel the rotate gesture。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_ROTATE}. - * @param callback The User Cancels the Callback function. - * @since 9 - */ - function off(type: MotionType.TYPE_ROTATE, callback?: Callback): void; + type MotionType = 'pickUp' | 'closeToEar' | 'flip' | 'shake' | 'rotate'; /** - * Cancels the two-finger event gesture。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_TWO_FINGER_PINCH}. - * @param callback The User Cancels the Callback function. + * 订阅手势状态。 + * @param motion 手势状态类型,{@code type: MotionType}。 + * @param callback 用于接收上报数据的回调。 + * @sysCap SystemCapability.Msdp.Motion * @since 9 */ - function off(type: MotionType.TYPE_TWO_FINGER_PINCH, callback?: Callback): void; + function on(motion: MotionType, callback: Callback): void; /** - * Cancels from the three-finger event gesture。 - * @param Cancels the gesture state type, {@code type: MotionType.TYPE_THREE_FINGERS_SLIDE}. - * @param callback The User Cancels the Callback function. + * 取消订阅手势状态。 + * @param motion 手势状态类型,{@code type: MotionType}。 + * @param callback 用于接收上报数据的回调。 + * @sysCap SystemCapability.Msdp.Motion * @since 9 */ - function off(type: MotionType.TYPE_THREE_FINGERS_SLIDE, callback?: Callback): void; + function off(motion: MotionType, callback?: Callback): void; } export default motion; diff --git a/api/@ohos.movement.d.ts b/api/@ohos.movement.d.ts index a9bc11c9f1..3c5fd22ab9 100644 --- a/api/@ohos.movement.d.ts +++ b/api/@ohos.movement.d.ts @@ -16,188 +16,100 @@ import { Callback } from "./basic"; /** - * Subscribe to user move status notifications + * 提供移动状态上报功能,可上报走、跑、骑、乘等事件。 * * @since 9 * @syscap SystemCapability.Msdp.Movement - * @import import sensor from '@ohos.movement' - * @permission N/A + * @import import movement from '@ohos.movement' */ declare namespace movement { /** - * The basic data structure of a move state event。 + * 用于接收移动状态。 * @syscap SystemCapability.Msdp.Movement + * @since 9 */ - export interface MovementResponse { - movementValue: MovementValue + interface MovementResponse { + state: MovementState; } /** - * Data on ride events。 - * @syscap SystemCapability.Msdp.Movement - */ - export interface InAutoResponse extends MovementResponse {} - - /** - * Data on cycling events。 - * @syscap SystemCapability.Msdp.Movement - */ - export interface OnBicycleResponse extends MovementResponse {} - - /** - * Walk the data of the event。 - * @syscap SystemCapability.Msdp.Movement - */ - export interface WalkingResponse extends MovementResponse {} - - /** - * Data for running events。 - * @syscap SystemCapability.Msdp.Movement - */ - export interface RuningResponse extends MovementResponse {} - - /** - * The move state type。 + * 移动状态类型。 * @syscap SystemCapability.Msdp.Movement + * @since 9 */ - export enum MovementType { - TYPE_IN_AUTO = "inAuto", - TYPE_ON_BICYCLE = "inBicycle", - TYPE_WALKING = "walking", - TYPE_RUNNING = "running", - } + type MovementType = 'inAuto' | 'inBicycle' | 'walking' | 'running'; /** - * The move status value。 + * 移动状态事件。 * @syscap SystemCapability.Msdp.Movement + * @since 9 */ - export enum MovementValue { + enum MovementEvent { + /** + * 进入移动状态。 + */ ENTER = 1, + + /** + * 退出移动状态。 + */ EXIT = 2, + + /** + * 进入和退出移动状态。 + */ ENTER_EXIT = 3 } - /** - * Subscribe to notifications of the mobility status of your ride。 - * - * @since 9 - * @param type Subscribe to notifications of the mobility status of your ride, {@code type: MovementType.TYPE_IN_AUTO}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: MovementType.TYPE_IN_AUTO, eventType: MovementValue, reportLatencyNs: number, callback: Callback): void; - - /** - * Subscribe to notifications of the movement status of your bike。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_ON_BICYCLE}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: MovementType.TYPE_ON_BICYCLE, eventType: MovementValue, reportLatencyNs: number, callback: Callback): void; - - /** - * Subscribe to mobile status notifications for walks。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_WALKING}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: MovementType.TYPE_WALKING, eventType: MovementValue, reportLatencyNs: number, callback: Callback): void; - - /** - * Subscribe to notifications of the movement status of your run。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_RUNNING}. - * @param eventType enter and exit event. - * @param reportLatencyNs report event latency. - * @param callback callback function, receive reported data. - */ - function on(type: MovementType.TYPE_RUNNING, eventType: MovementValue, reportLatencyNs: number, callback: Callback): void; - - /** - * Check if you are in the car。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code MovementType.TYPE_IN_AUTO}. - * @param callback callback function, receive reported data. - */ - function once(type: MovementType.TYPE_IN_AUTO, callback: Callback): void; - - - /** - * Check if you're riding a bike。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code MovementType.TYPE_ON_BICYCLE}. - * @param callback callback function, receive reported data. - */ - function once(type: MovementType.TYPE_ON_BICYCLE, callback: Callback): void; - - - /** - * Query whether it is the status of walking。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code MovementType.TYPE_WALKING}. - * @param callback callback function, receive reported data. - */ - function once(type: MovementType.TYPE_WALKING, callback: Callback): void; - - /** - * Query whether it is the status of running。 - * - * @since 9 - * @param type The mobile state type of the subscription, {@code MovementType.TYPE_RUNNING}. - * @param callback callback function, receive reported data. - */ - function once(type: MovementType.TYPE_RUNNING, callback: Callback): void; - - /** - * Unsubscribe from the ride's mobile status notification。 - * + /** + * 移动状态。 + * @syscap SystemCapability.Msdp.Movement * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_IN_AUTO}. - * @param eventType enter and exit event. - * @param callback callback function, receive reported data. */ - function off(type: MovementType.TYPE_IN_AUTO, eventType: MovementValue, callback?: Callback): void; + enum MovementState { + /** + * 进入移动状态。 + */ + ENTER = 1, + + /** + * 退出移动状态。 + */ + EXIT = 2 + } /** - * Unsubscribe from the bike's mobile status notification。 + * 订阅移动状态。 * + * @param movement 移动状态类型,{@code movement: MovementType}。 + * @param event 移动状态事件。 + * @param reportLatencyNs 事件上报周期。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Movement * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_ON_BICYCLE}. - * @param eventType enter and exit event. - * @param callback callback function, receive reported data. */ - function off(type: MovementType.TYPE_ON_BICYCLE, eventType: MovementValue, callback?: Callback): void; - + function on(movement: MovementType, event: MovementEvent, reportLatencyNs: number, callback: Callback): void; + /** - * Unsubscribe from mobile status notifications for walks。 + * 查询当前移动状态。 * + * @param movement 移动状态类型,{@code MovementType}。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Movement * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_WALKING}. - * @param eventType enter and exit event. - * @param callback callback function, receive reported data. */ - function off(type: MovementType.TYPE_WALKING, eventType: MovementValue, callback?: Callback): void; + function once(movement: MovementType, callback: Callback): void; /** - * Unsubscribe from the run's motion status notification。 + * 取消订阅移动状态。 * + * @param movement 移动状态类型,{@code movement: MovementType}。 + * @param event 移动状态事件。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Movement * @since 9 - * @param type The mobile state type of the subscription, {@code type: MovementType.TYPE_RUNNING}. - * @param eventType enter and exit event. - * @param callback callback function, receive reported data. */ - function off(type: MovementType.TYPE_RUNNING, eventType: MovementValue, callback?: Callback): void; + function off(movement: MovementType, event: MovementEvent, callback?: Callback): void; } export default movement; diff --git a/api/@ohos.spatialAwareness.d.ts b/api/@ohos.spatialAwareness.d.ts index 017203ef0f..3953cf12c4 100644 --- a/api/@ohos.spatialAwareness.d.ts +++ b/api/@ohos.spatialAwareness.d.ts @@ -16,223 +16,191 @@ import { Callback } from './basic'; /** - * Provides registration and deregistration interfaces for spatial location - relationships between multiple devices, which are defined as follows: - * {@link on}: Subscribe to location relationships between devices - * {@link off}: Unsubscribe from the inter-device location relationship - * + * 提供设备空间感知数据上报功能,可上报方位关系、接近关系等事件。 + * * @since 9 * @syscap SystemCapability.Msdp.SpatialAwareness - * @permission N/A + * @import import spatialAwareness from '@ohos.spatialAwareness' */ declare namespace spatialAwareness { /** - * Bearing relationship definition。 - * @name DirectionResponse + * 用于接收方位数据。 + * @syscap SystemCapability.Msdp.SpatialAwareness + * @since 9 */ - export interface DirectionResponse { + interface DirectionResponse { direction : Direction } - - /** - * Approach the relationship definition。 - * @name NearByResponse - */ - export interface NearByResponse { - nearby : boolean; - } - - /** - * Distance relationship definition。 - * @name DistanceResponse - */ - export interface DistanceBTResponse { - distance : number; - } /** - * Device information definition。 + * 设备信息定义。 + * + * @syscap SystemCapability.Msdp.SpatialAwareness + * @since 9 */ - export interface DeviceInfo { + interface DeviceInfo { /** - * Device ID。 + * 设备ID。 */ deviceId: string; /** - * Device name。 + * 设备名称。 */ deviceName: string; /** - * Device type。 + * 设备类型。 */ deviceType: DeviceType; } /** - * Location information definition。 - * @name PositionRelation + * 位置关系类型。 + * + * @syscap SystemCapability.Msdp.SpatialAwareness + * @since 9 */ - export enum PositionRelation { + enum PositionRelation { /** - * Represents an azimuth relationship。 + * 方位关系。 */ DIRECTION = "direction", + /** - * Represents a distance relationship。 - */ - DISTANCE_BT = "distanceBT", - /** - * Represents a proximity relationship。 + * 接近关系。 */ NEARBY = "nearby" } /** - * Device type definition。 - * @name DeviceType + * 设备类型。 + * + * @syscap SystemCapability.Msdp.SpatialAwareness + * @since 9 */ - export enum DeviceType { + enum DeviceType { /** - * Represents an unknown device type。 + * 表示未知的设备类型。 */ UNKNOWN_TYPE = 1, /** - * Represents a speaker。 + * 表示音响。 */ SPEAKER = 2, /** - * Represents a smartphone。 + * 表示智能手机。 */ PHONE = 3, /** - * Represents a tablet。 + * 表示平板电脑。 */ TABLET = 4, /** - * Represents a smart wearable device。 + * 表示穿戴设备。 */ WEARABLE = 5, /** - * Represents a car。 + * 表示汽车。 */ CAR = 6, /** - * Represents a Smart TV。 + * 表示智能电视。 */ TV = 7 } /** - * Azimuth relationship pattern definition。 - * @name Direction + * 方位关系定义。 + * + * @syscap SystemCapability.Msdp.SpatialAwareness + * @since 9 */ - export enum Direction { + enum Direction { /** - * Represents the left side of the requesting device。 + * 表示在请求设备的左边。 */ LEFT = 1, + /** - * Represents the right side of the requesting device。 + * 表示在请求设备的右边。 */ RIGHT = 2, + /** - * Represented in front of the requesting device。 + * 表示在请求设备的前面。 */ FRONT = 3, + /** - * Represented after the requested device。 + * 表示在请求设备的后面。 */ BACK = 4, + /** - * Represented above the requesting device。 + * 表示在请求设备的上面。 */ UP = 5, + /** - * Represented below the requesting device。 + * 表示在请求设备的下面。 */ DOWN = 6 } /** - * Spatial azimuth relationships between subscription devices。 + * 订阅设备间方位关系。 * - * @since 9 + * @param type 方位关系,{@code PositionRelation}。 + * @param deviceInfo 目标设备信息,{@code DeviceInfo}。 + * @param callback 用于接收上报数据的回调。 * @syscap SystemCapability.Msdp.SpatialAwareness - * @param type Represents the device-to-device relationship type for a subscription {@code PositionRelation}. - * @param deviceInfo Represents the device information to subscribe to {@code DeviceInfo}. - * @param callback callback function, receive reported data + * @since 9 */ function on(type: PositionRelation.DIRECTION, deviceInfo : DeviceInfo, - callback: Callback<{ directionRes : DirectionResponse }>): void; + callback: Callback): void; /** - * Spatial proximity between subscription devices。 + * 订阅设备间接近关系。 * - * @since 9 + * @param type 方位关系,{@code PositionRelation}。 + * @param deviceInfo 目标设备信息,{@code DeviceInfo}。 + * @param callback 用于接收上报数据的回调。 * @syscap SystemCapability.Msdp.SpatialAwareness - * @param type Represents the device-to-device relationship type for a subscription {@code PositionRelation}. - * @param deviceInfo Represents the device information to subscribe to {@code DeviceInfo}. - * @param callback callback function, receive reported data + * @since 9 */ function on(type: PositionRelation.NEARBY, deviceInfo : DeviceInfo, - callback: Callback<{ nearbyRes: NearByResponse }>): void; + callback: Callback): void; /** - * Spatial distance relationship between subscription devices。 + * 取消订阅设备间方位关系。 * - * @since 9 + * @param type 方位关系,{@code PositionRelation}。 + * @param deviceInfo 目标设备信息,{@code DeviceInfo}。 + * @param callback 用于接收上报数据的回调。 * @syscap SystemCapability.Msdp.SpatialAwareness - * @param type Represents the device-to-device relationship type for a subscription {@code PositionRelation}. - * @param deviceInfo Represents the device information to subscribe to {@code DeviceInfo}. - * @param callback callback function, receive reported data - */ - function on(type: PositionRelation.DISTANCE_BT, deviceInfo : DeviceInfo, - callback: Callback<{ distanceRes : DistanceBTResponse }>): void; - - - /** - * Unsubscribe from spatial azimuth relationships between devices。 - * * @since 9 - * @syscap SystemCapability.Msdp.SpatialAwareness - * @param type Unsubscribe from spatial azimuth relationships between devices {@code PositionRelation}. - * @param deviceInfo Represents device information for unsubscribed {@code DeviceInfo}. - * @param callback callback function, receive reported data */ function off(type: PositionRelation.DIRECTION, deviceInfo : DeviceInfo, - callback?: Callback<{ directionRes : DirectionResponse }>): void; + callback?: Callback): void; /** - * Unsubscribe from the space proximity relationship between devices。 + * 取消订阅设备间接近关系。 * - * @since 9 + * @param type 方位关系,{@code PositionRelation}。 + * @param deviceInfo 目标设备信息,{@code DeviceInfo}。 + * @param callback 用于接收上报数据的回调。 * @syscap SystemCapability.Msdp.SpatialAwareness - * @param type Represents the device-to-device relationship type for a subscription {@code PositionRelation}. - * @param deviceInfo Represents device information for unsubscribed {@code DeviceInfo}. - * @param callback callback function, receive reported data - */ - function off(type: PositionRelation.NEARBY, deviceInfo : DeviceInfo, - callback?: Callback<{ nearbyRes: NearByResponse }>): void; - - /** - * Unsubscribe from the spatial distance relationship between devices。 - * * @since 9 - * @syscap SystemCapability.Msdp.SpatialAwareness - * @param type Represents the device-to-device relationship type for a subscription {@code PositionRelation}. - * @param deviceInfo Represents device information for unsubscribed {@code DeviceInfo}. - * @param callback callback function, receive reported data */ - function off(type: PositionRelation.DISTANCE_BT, deviceInfo : DeviceInfo, - callback?: Callback<{ distanceRes : DistanceBTResponse }>): void; + function off(type: PositionRelation.NEARBY, deviceInfo : DeviceInfo, + callback?: Callback): void; } export default spatialAwareness; \ No newline at end of file diff --git a/api/@ohos.timeline.d.ts b/api/@ohos.timeline.d.ts new file mode 100644 index 0000000000..32d811201d --- /dev/null +++ b/api/@ohos.timeline.d.ts @@ -0,0 +1,165 @@ +/* + * 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"; + +/** + * 提供时间线数据上报功能,可上报位于家或者位于公司事件。 + * + * @since 9 + * @syscap SystemCapability.Msdp.Timeline + * @import import timeline from '@ohos.timeline' + */ +declare namespace timeline { + /** + * 用于接收时间线数据。 + * + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + export class TimelineResponse { + state: TimelineState; + } + + /** + * 时间线类型。 + * + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + type TimelineArea = 'areaHome' | 'areaCompany'; + + /** + * 时间类型。 + * + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + type ActivityTime = 'sleepTime' | 'restTime' | 'workTime'; + + /** + * 时间线事件。 + * + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + enum TimelineEvent { + /** + * 进入时间线。 + */ + ENTER = 1, + + /** + * 退出时间线。 + */ + EXIT = 2, + + /** + * 进入和退出时间线。 + */ + ENTER_EXIT = 3 + } + + /** + * 时间线状态. + * + * @syscap SystemCapability.Msdp.DeviceStatus + * @since 9 + */ + enum TimelineState { + /** + * 进入时间线。 + */ + ENTER = 1, + + /** + * 退出时间线。 + */ + EXIT = 2 + } + + /** + * 订阅时间线。 + * + * @param area 时间线类型,{@code TimelineArea}。 + * @param event 时间线事件。 + * @param callback 用于接收上报数据的回调。 + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function on(area: TimelineArea, event:TimelineEvent, callback: Callback): void; + + /** + * 取消订阅时间线。 + * + * @param area 时间线类型,{@code TimelineArea}. + * @param callback 用于接收上报数据的回调. + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function off(area: TimelineArea, callback?: Callback): void; + + /** + * 设置地理位置。 + * + * @param area 时间线类型,{@code TimelineArea}. + * @param longitude 经度。 + * @param latitude 纬度。 + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function setPosition(area: TimelineArea, longitude: number, latitude: number): void; + + /** + * 设置白班或者夜班。 + * + * @param value 白班或者夜班,取值范围是[0,1],0表示白班,1表示夜班。 + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function setDayAndNightShift(value: number): void; + + /** + * 设置时间段。 + * + * @param time 时间段活动类型。 + * @param start 起始时间,取值范围是[0,23]。 + * @param end 结束时间,取值范围是[0,23]。 + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function setTime(time: ActivityTime, start: number, end: number): void; + + /** + * 获取指定时间的预测结果。 + * + * @param hour 指定的时间,取值范围是[0,23]。 + * @param callback 用于接收时间线上报数据的回调。 + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function getForecastPosition(hour: number, callback: Callback): void + + /** + * 获取指定时间的预测结果。 + * + * @param hour 指定的时间,取值范围是[0,23]。 + * @syscap SystemCapability.Msdp.Timeline + * @since 9 + */ + function getForecastPosition(hour: number): Promise(TimelineArea) +} + +export default timeline; -- Gitee