1 /* 2 * Copyright (c) 2023 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 #ifndef STATIONARY_MANAGER_H 17 #define STATIONARY_MANAGER_H 18 19 #include <functional> 20 #include <memory> 21 22 #include "nocopyable.h" 23 24 #include "devicestatus_common.h" 25 #include "iremote_dev_sta_callback.h" 26 #include "stationary_data.h" 27 28 namespace OHOS { 29 namespace Msdp { 30 namespace DeviceStatus { 31 class StationaryManager { 32 public: 33 /** 34 * @brief Obtains a <b>StationaryManager</b> instance. 35 * @return Returns a <b>StationaryManager</b> instance. 36 * @since 9 37 */ 38 static StationaryManager& GetInstance(); 39 40 /** 41 * @brief Subscribes to device status changes. 42 * @param type Indicates the device status type. 43 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 44 * @param latency Indicates the reporting interval. 45 * @param callback Indicates the callback used to return the device status changes. 46 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 47 * @since 9 48 */ 49 int32_t SubscribeCallback(Type type, ActivityEvent event, ReportLatencyNs latency, 50 sptr<IRemoteDevStaCallback> callback); 51 52 /** 53 * @brief Unsubscribes from device status changes. 54 * @param type Indicates the device status type. 55 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 56 * @param callback Indicates the callback used to return the device status changes. 57 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 58 * @since 9 59 */ 60 int32_t UnsubscribeCallback(Type type, ActivityEvent event, sptr<IRemoteDevStaCallback> callback); 61 62 /** 63 * @brief Obtains the device status data. 64 * @param type Indicates the device status type. 65 * @return Returns the device status data. 66 * @since 9 67 */ 68 Data GetDeviceStatusData(const Type type); 69 70 /** 71 * @brief sync obtain device posture data 72 * @param data Indicates posture data which returned by service 73 * @return Returns retcode 74 * @since 20 75 */ 76 int32_t GetDevicePostureDataSync(DevicePostureData &data); 77 private: 78 StationaryManager() = default; 79 DISALLOW_COPY_AND_MOVE(StationaryManager); 80 }; 81 } // namespace DeviceStatus 82 } // namespace Msdp 83 } // namespace OHOS 84 #endif // STATIONARY_MANAGER_H