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 HDI_LIGHT_CONNECTION_H
17 #define HDI_LIGHT_CONNECTION_H
18 
19 #include "death_recipient_template.h"
20 #include "i_light_hdi_connection.h"
21 #include "v1_0/light_interface_proxy.h"
22 
23 namespace OHOS {
24 namespace Sensors {
25 using OHOS::HDI::Light::V1_0::ILightInterface;
26 class HdiLightConnection : public ILightHdiConnection {
27 public:
28     HdiLightConnection() = default;
~HdiLightConnection()29     virtual ~HdiLightConnection() {};
30     int32_t ConnectHdi() override;
31     int32_t GetLightList(std::vector<LightInfoIPC> &lightList) override;
32     int32_t TurnOn(int32_t lightId, const LightColor &color, const LightAnimationIPC &animation) override;
33     int32_t TurnOff(int32_t lightId) override;
34     int32_t DestroyHdiConnection() override;
35     void ProcessDeathObserver(const wptr<IRemoteObject> &object);
36 
37 private:
38     DISALLOW_COPY_AND_MOVE(HdiLightConnection);
39     sptr<IRemoteObject::DeathRecipient> hdiDeathObserver_ = nullptr;
40     sptr<ILightInterface> lightInterface_ = nullptr;
41     void RegisterHdiDeathRecipient();
42     void UnregisterHdiDeathRecipient();
43     void Reconnect();
44 };
45 }  // namespace Sensors
46 }  // namespace OHOS
47 #endif  // HDI_LIGHT_CONNECTION_H