1 /* 2 * Copyright (c) 2025 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_HDI_SENSOR_V3_0_SENSORCALLBACKIMPL_H 17 #define OHOS_HDI_SENSOR_V3_0_SENSORCALLBACKIMPL_H 18 19 #include <hdf_base.h> 20 #include "v3_0/isensor_plug_callback.h" 21 #include "hdf_log.h" 22 23 namespace OHOS { 24 namespace HDI { 25 namespace Sensor { 26 namespace V3_0 { 27 class SensorPlugCallbackImpl : public ISensorPlugCallback { 28 public: ~SensorPlugCallbackImpl()29 virtual ~SensorPlugCallbackImpl() {} 30 OnSensorPlugEvent(const SensorPlugInfo & sensorPlugInfo)31 int32_t OnSensorPlugEvent(const SensorPlugInfo& sensorPlugInfo) override 32 { 33 DeviceSensorInfo sensorHandle = sensorPlugInfo.deviceSensorInfo; 34 std::string deviceSensorInfo = ("deviceId" + std::to_string((sensorHandle).deviceId) + "sensorType" + 35 std::to_string((sensorHandle).sensorType) + "sensorId" + std::to_string((sensorHandle).sensorId) + 36 "location" + std::to_string((sensorHandle).location)); 37 printf("OnSensorPlugEvent deviceSensorInfo[%s]deviceName[%s]status[%d]reserved[%d]", 38 deviceSensorInfo.c_str(), sensorPlugInfo.deviceName.c_str(), 39 sensorPlugInfo.status, sensorPlugInfo.reserved); 40 HDF_LOGI("OnSensorPlugEvent deviceSensorInfo[%{public}s]deviceName[%{public}s]status[%{public}d]" 41 "reserved[%{public}d]", 42 deviceSensorInfo.c_str(), sensorPlugInfo.deviceName.c_str(), 43 sensorPlugInfo.status, sensorPlugInfo.reserved); 44 return HDF_SUCCESS; 45 } 46 }; 47 } // V3_0 48 } // Sensor 49 } // HDI 50 } // OHOS 51 52 #endif // OHOS_HDI_SENSOR_V1_1_SENSORCALLBACKIMPL_H 53