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_SOURCE_SERVICE_H
17 #define OHOS_DSCREEN_SOURCE_SERVICE_H
18 
19 #include "system_ability.h"
20 #include "ipc_object_stub.h"
21 
22 #include "1.0/include/dscreen_manager.h"
23 #include "2.0/include/dscreen_manager.h"
24 #include "dscreen_source_stub.h"
25 #include "idscreen_source_callback.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class DScreenSourceService : public SystemAbility, public DScreenSourceStub,
30     public std::enable_shared_from_this<DScreenSourceService> {
31 DECLARE_SYSTEM_ABILITY(DScreenSourceService);
32 public:
33     DScreenSourceService(int32_t saId, bool runOnCreate);
34     ~DScreenSourceService() override = default;
35     int32_t InitSource(const std::string &params, const sptr<IDScreenSourceCallback> &callback) override;
36     int32_t ReleaseSource() override;
37     int32_t RegisterDistributedHardware(const std::string &devId, const std::string &dhId,
38         const EnableParam &param, const std::string &reqId) override;
39     int32_t UnregisterDistributedHardware(const std::string &devId, const std::string &dhId,
40         const std::string &reqId) override;
41     int32_t ConfigDistributedHardware(const std::string &devId, const std::string &dhId, const std::string &key,
42         const std::string &value) override;
43     void DScreenNotify(const std::string &devId, const int32_t eventCode, const std::string &eventContent) override;
44     int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override;
45 
46 protected:
47     void OnStart() override;
48     void OnStop() override;
49     DISALLOW_COPY_AND_MOVE(DScreenSourceService);
50 
51 private:
52     bool Init();
53     void DeleteExistDScreens();
54 
55     bool registerToService_ = false;
56 };
57 } // namespace DistributedHardware
58 } // namespace OHOS
59 #endif