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 16/** 17 * @addtogroup HdiActivityRecognition 18 * @{ 19 * 20 * @brief Provides APIs for subscribing to and obtaining user activities. 21 * 22 * The Multimodal Sensor Data Platform (MSDP) can obtain the object or proxy of the activity recognition driver, 23 * and call the APIs provided by the object or proxy to obtain activities supported by the device, 24 * the current activity event of the device, and activity events cached on the device, 25 * and subscribe to or unsubscribe from activity events. 26 * 27 * @since 3.2 28 * @version 1.0 29 */ 30 31/** 32 * @file IActivityInterface.idl 33 * 34 * @brief Declares the APIs provided by the activity recognition module. These APIs can be used to obtain the activities 35 * supported by the device, the current activity event of the device, and the activity events cached on the device, 36 * and subscribe to or unsubscribe from activity events. 37 * 38 * @since 3.2 39 * @version 1.0 40 */ 41 42/** 43 * @brief Defines the package path of the activity recognition module APIs. 44 * 45 * @since 3.2 46 */ 47package ohos.hdi.activity_recognition.v1_0; 48 49import ohos.hdi.activity_recognition.v1_0.ActivityRecognitionTypes; 50import ohos.hdi.activity_recognition.v1_0.IActivityChangedCallback; 51 52/** 53 * @brief Defines the APIs for performing basic operations of activity recognition. 54 * 55 * The APIs can be used to register or unregister a callback, obtain the activities supported by the device, 56 * the current activity event of the device, the activity events cached on the device, 57 * and subscribe to and unsubscribe from activity events. 58 */ 59interface IActivityInterface { 60 /** 61 * @brief Registers a callback. 62 * 63 * Before obtaining the current activity event or the activity events cached on the device, 64 * you must register this callback so that data can be reported through it. 65 * 66 * @param callbackObj Indicates the callback to register, which needs to be registered only once. 67 * For details, see {@link IActivityChangedCallback}. 68 * 69 * @return Returns <b>0</b> if the operation is successful. 70 * @return Returns a negative value if the operation fails. 71 * 72 * @since 3.2 73 * @version 1.0 74 */ 75 RegisterActRecognitionCallback([in] IActivityChangedCallback callbackObj); 76 77 /** 78 * @brief Unregisters a callback. 79 * 80 * If activity recognition is not required or another callback needs to be used, you must unregister the current callback. 81 * 82 * @param callbackObj Indicates the callback to unregister, which needs to be unregistered only once. 83 * For details, see {@link IActivityChangedCallback}. 84 * 85 * @return Returns <b>0</b> if the operation is successful. 86 * @return Returns a negative value if the operation fails. 87 * 88 * @since 3.2 89 * @version 1.0 90 */ 91 UnregisterActRecognitionCallback([in] IActivityChangedCallback callbackObj); 92 93 /** 94 * @brief Obtains the activities supported by the device. 95 * 96 * @param activity Indicates the activities supported. The value is a string 97 * and can be "inVehicle", "onBicycle", "walking", "running", "still", "fast_walking", "high_speed_rail", 98 * "unknown", "elevator", "relative_still", "walking_handhold", "lying_posture", "plane", "metro", and more. 99 * For details, see {@link ActRecognitionEventType}. 100 * 101 * @return Returns <b>0</b> if the operation is successful. 102 * @return Returns a negative value if the operation fails. 103 * 104 * @since 3.2 105 * @version 1.0 106 */ 107 GetSupportActivity([out] String[] activity); 108 109 /** 110 * @brief Obtains the current activity events of the device. 111 * 112 * Before calling this API, you must use {@link EnableActRecognitionEvent} to subscribe to an activity event. 113 * 114 * @param event Indicates the current activity events. For details, see {@link ActRecognitionEvent}. 115 * 116 * @return Returns <b>0</b> if the operation is successful. 117 * @return Returns a negative value if the operation fails. 118 * 119 * @since 3.2 120 * @version 1.0 121 */ 122 GetCurrentActivity([out] struct ActRecognitionEvent[] event); 123 124 /** 125 * @brief Subscribe to an activity event. 126 * 127 * If the subscribed activity event occurs, the activity event is reported within a specified period. 128 * 129 * @param activity Indicates the activity. You can call {@link GetSupportActivity} to obtain all activities supported by 130 * the device, and pass the subscript of the desired activity through this API. 131 * @param eventType Indicates the event type. For details, see {@link ActRecognitionEventType}. You can fill in 132 * <b>1</b> (entering the activity), <b>2</b> (exiting the activity), or <b>3</b> (entering and exiting the activity). 133 * @param maxReportLatencyNs Indicates the maximum report interval, in nanoseconds. If the subscribed activity event 134 * occurs within the interval, the event is reported. If multiple intervals are set in subscriptions, 135 * the minimum interval is used. 136 * @param powerMode Indicates the power consumption mode. For details, see {@link ActRecognitionPowerMode}. 137 * 138 * @return Returns <b>0</b> if the operation is successful. 139 * @return Returns a negative value if the operation fails. 140 * 141 * @since 3.2 142 * @version 1.0 143 */ 144 EnableActRecognitionEvent([in] int activity, [in] int eventType, [in] long maxReportLatencyNs, [in] int powerMode); 145 146 /** 147 * @brief Unsubscribes from an activity event. 148 * 149 * 150 * 151 * @param activity Indicates the activity. For details, see the <b>activity</b> parameter 152 * in {@link EnableActRecognitionEvent}. 153 * @param eventType Indicates the event type. For details, see {@link ActRecognitionEventType}. You can fill in 154 * <b>1</b> (entering the activity), <b>2</b> (exiting the activity), or <b>3</b> (entering and exiting the activity). 155 * 156 * @return Returns <b>0</b> if the operation is successful. 157 * @return Returns a negative value if the operation fails. 158 * 159 * @since 3.2 160 * @version 1.0 161 */ 162 DisableActRecognitionEvent([in] int activity, [in] int eventType); 163 164 /** 165 * @brief Flushes all the activity events cached on the device and reports them. 166 * 167 * 168 * 169 * @return Returns <b>0</b> if the operation is successful. 170 * @return Returns a negative value if the operation fails. 171 * 172 * @since 3.2 173 * @version 1.0 174 */ 175 FlushActivity(); 176} 177/** @} */