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 }; 32 33 class DScreenHandler : public IHardwareHandler { 34 DECLARE_SINGLE_INSTANCE_BASE(DScreenHandler); 35 public: 36 int32_t Initialize() override; 37 std::vector<DHItem> Query() override; 38 std::map<std::string, std::string> QueryExtraInfo() override; 39 bool IsSupportPlugin() override; 40 void RegisterPluginListener(std::shared_ptr<PluginListener> listener) override; 41 void PluginHardware(const std::string &dhId, const std::string &attr); 42 void UnPluginHardware(const std::string &dhId); 43 std::string QueryCodecInfo(); 44 45 private: 46 DScreenHandler(); 47 ~DScreenHandler(); 48 49 std::shared_ptr<PluginListener> listener_ = nullptr; 50 std::string codecInfoStr_; 51 sptr<ScreenListener> screenListener_ = nullptr; 52 }; 53 54 #ifdef __cplusplus 55 extern "C" { 56 #endif 57 __attribute__((visibility("default"))) IHardwareHandler* GetHardwareHandler(); 58 #ifdef __cplusplus 59 } 60 #endif 61 } // namespace DistributedHardware 62 } // namespace OHOS 63 #endif