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 BOOMERANG_MANAGER_H 17 #define BOOMERANG_MANAGER_H 18 19 #include <functional> 20 #include <memory> 21 22 #include "nocopyable.h" 23 24 #include "boomerang_data.h" 25 #include "devicestatus_common.h" 26 #include "iremote_boomerang_callback.h" 27 28 namespace OHOS { 29 namespace Msdp { 30 namespace DeviceStatus { 31 class BoomerangManager { 32 public: 33 34 /** 35 * @brief Obtains a <b>BoomerangManager</b> instance. 36 * @return Returns a <b>BoomerangManager</b> instance. 37 * @since 9 38 */ 39 static BoomerangManager& GetInstance(); 40 41 /** 42 * @brief Subscribes to device status changes. 43 * @param type Indicates the device status type. 44 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 45 * @param latency Indicates the reporting interval. 46 * @param callback Indicates the callback used to return the device status changes. 47 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 48 * @since 9 49 */ 50 int32_t SubscribeCallback(BoomerangType type, std::string bundleName, sptr<IRemoteBoomerangCallback> 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(BoomerangType type, std::string bundleName, sptr<IRemoteBoomerangCallback> callback); 61 62 /** 63 * @brief Unsubscribes from device status changes. 64 * @param type Indicates the device status type. 65 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 66 * @param callback Indicates the callback used to return the device status changes. 67 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 68 * @since 9 69 */ 70 int32_t NotifyMetadataBindingEvent(std::string bundleName, sptr<IRemoteBoomerangCallback> callback); 71 72 /** 73 * @brief Unsubscribes from device status changes. 74 * @param type Indicates the device status type. 75 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 76 * @param callback Indicates the callback used to return the device status changes. 77 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 78 * @since 9 79 */ 80 int32_t SubmitMetadata(std::string metadata); 81 82 /** 83 * @brief Unsubscribes from device status changes. 84 * @param type Indicates the device status type. 85 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 86 * @param callback Indicates the callback used to return the device status changes. 87 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 88 * @since 9 89 */ 90 int32_t BoomerangEncodeImage(std::shared_ptr<Media::PixelMap> pixelMap, std::string matedata, 91 sptr<IRemoteBoomerangCallback> callback); 92 93 /** 94 * @brief Unsubscribes from device status changes. 95 * @param type Indicates the device status type. 96 * @param event Indicates the event type, which can be <b>ENTER</b>, <b>EXIT</b>, and <b>ENTER_EXIT</b>. 97 * @param callback Indicates the callback used to return the device status changes. 98 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 99 * @since 9 100 */ 101 int32_t BoomerangDecodeImage(std::shared_ptr<Media::PixelMap> pixelMap, sptr<IRemoteBoomerangCallback> callback); 102 private: 103 BoomerangManager() = default; 104 DISALLOW_COPY_AND_MOVE(BoomerangManager); 105 }; 106 } // namespace DeviceStatus 107 } // namespace Msdp 108 } // namespace OHOS 109 #endif // BOOMERANG_MANAGER_H