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 #include "distributed_device_callback.h"
17 
18 #include "ans_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace Notification {
DistributedDeviceCallback(const IDeviceChange & callback)22 DistributedDeviceCallback::DistributedDeviceCallback(const IDeviceChange &callback) : callback_(callback)
23 {}
~DistributedDeviceCallback()24 DistributedDeviceCallback::~DistributedDeviceCallback()
25 {}
26 
OnDeviceOnline(const DistributedHardware::DmDeviceInfo & deviceInfo)27 void DistributedDeviceCallback::OnDeviceOnline(const DistributedHardware::DmDeviceInfo &deviceInfo)
28 {
29     ANS_LOGI("start");
30     if (callback_.OnConnected) {
31         ANS_LOGI("device is online");
32         callback_.OnConnected(deviceInfo.deviceId);
33     }
34 }
35 
OnDeviceOffline(const DistributedHardware::DmDeviceInfo & deviceInfo)36 void DistributedDeviceCallback::OnDeviceOffline(const DistributedHardware::DmDeviceInfo &deviceInfo)
37 {
38     ANS_LOGI("start");
39     if (callback_.OnConnected) {
40         ANS_LOGI("device is offline");
41         callback_.OnDisconnected(deviceInfo.deviceId);
42     }
43 }
44 
OnDeviceChanged(const DistributedHardware::DmDeviceInfo & deviceInfo)45 void DistributedDeviceCallback::OnDeviceChanged(const DistributedHardware::DmDeviceInfo &deviceInfo)
46 {
47     ANS_LOGI("device is changed");
48 }
49 
OnDeviceReady(const DistributedHardware::DmDeviceInfo & deviceInfo)50 void DistributedDeviceCallback::OnDeviceReady(const DistributedHardware::DmDeviceInfo &deviceInfo)
51 {
52     ANS_LOGI("device is ready");
53 }
54 }  // namespace Notification
55 }  // namespace OHOS
56