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