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 #ifndef OHOS_DSCREEN_HANDLER_H 17 #define OHOS_DSCREEN_HANDLER_H 18 19 #include "screen_manager.h" 20 21 #include "ihardware_handler.h" 22 #include "single_instance.h" 23 24 namespace OHOS { 25 namespace DistributedHardware { 26 class ScreenListener : public Rosen::ScreenManager::IScreenListener { 27 public: 28 void OnConnect(uint64_t screenId) override; 29 void OnDisconnect(uint64_t screenId) override; OnChange(uint64_t screenId)30 void OnChange(uint64_t screenId) override {}; 31 uint32_t ByteCalculate(uint32_t screenWidth); 32 }; 33 34 class DScreenHandler : public IHardwareHandler { 35 DECLARE_SINGLE_INSTANCE_BASE(DScreenHandler); 36 public: 37 int32_t Initialize() override; 38 std::vector<DHItem> QueryMeta() override; 39 std::vector<DHItem> Query() override; 40 std::map<std::string, std::string> QueryExtraInfo() override; 41 bool IsSupportPlugin() override; 42 void RegisterPluginListener(std::shared_ptr<PluginListener> listener) override; 43 void UnRegisterPluginListener() override; 44 void PluginHardware(const std::string &dhId, const std::string &attr, const std::string &subtype); 45 void UnPluginHardware(const std::string &dhId); 46 std::string QueryCodecInfo(); 47 48 private: 49 DScreenHandler(); 50 ~DScreenHandler(); 51 52 std::shared_ptr<PluginListener> listener_ = nullptr; 53 std::string codecInfoStr_; 54 sptr<ScreenListener> screenListener_ = nullptr; 55 }; 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); 61 #ifdef __cplusplus 62 } 63 #endif 64 } // namespace DistributedHardware 65 } // namespace OHOS 66 #endif