1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { Callback } from "./basic"; 17 18/** 19 * Declares a namespace that provides APIs to report the device status. 20 * 21 * @since 9 22 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 23 */ 24declare namespace stationary { 25 /** 26 * Declares a response interface to receive the device status. 27 * 28 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 29 * @since 9 30 */ 31 interface ActivityResponse { 32 state: ActivityState; 33 } 34 35 /** 36 * Declares the device status type. 37 * 38 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 39 * @since 9 40 */ 41 type ActivityType = 'still' | 'relativeStill'; 42 43 /** 44 * Enumerates the device status events. 45 * 46 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 47 * @since 9 48 */ 49 enum ActivityEvent { 50 /** 51 * Event indicating entering device status. 52 */ 53 ENTER = 1, 54 55 /** 56 * Event indicating exiting device status. 57 */ 58 EXIT = 2, 59 60 /** 61 * Event indicating entering and exiting device status. 62 */ 63 ENTER_EXIT = 3 64 } 65 66 /** 67 * Declares a response interface to receive the device status. 68 * 69 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 70 * @since 9 71 */ 72 enum ActivityState { 73 /** 74 * Entering device status. 75 */ 76 ENTER = 1, 77 78 /** 79 * Exiting device status. 80 */ 81 EXIT = 2 82 } 83 84 /** 85 * Subscribes to the device status. 86 * 87 * @param activity Indicates the device status type. For details, see {@code type: ActivityType}. 88 * @param event Indicates the device status event. 89 * @param reportLatencyNs Indicates the event reporting period. 90 * @param callback Indicates the callback for receiving reported data. 91 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 92 * @since 9 93 */ 94 function on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback<ActivityResponse>): void; 95 96 /** 97 * Obtains the device status. 98 * 99 * @param activity Indicates the device status type. For details, see {@code type: ActivityType}. 100 * @param callback Indicates the callback for receiving reported data. 101 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 102 * @since 9 103 */ 104 function once(activity: ActivityType, callback: Callback<ActivityResponse>): void; 105 106 /** 107 * Unsubscribes from the device status. 108 * 109 * @param activity Indicates the device status type. For details, see {@code type: ActivityType}. 110 * @param event Indicates the device status event. 111 * @param callback Indicates the callback for receiving reported data. 112 * @syscap SystemCapability.Msdp.DeviceStatus.Stationary 113 * @since 9 114 */ 115 function off(activity: ActivityType, event: ActivityEvent, callback?: Callback<ActivityResponse>): void; 116} 117 118export default stationary; 119