1 /* 2 * Copyright (c) 2023 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 "sensor_callback_vdi.h" 17 18 namespace OHOS { 19 namespace HDI { 20 namespace Sensor { 21 namespace V1_1 { 22 OnDataEventVdi(const HdfSensorEventsVdi & eventVdi)23int32_t SensorCallbackVdi::OnDataEventVdi(const HdfSensorEventsVdi& eventVdi) 24 { 25 struct HdfSensorEvents event; 26 27 if (sensorCallback_ == nullptr) { 28 HDF_LOGE("%{public}s sensorCallback_ is NULL", __func__); 29 return HDF_FAILURE; 30 } 31 32 event.sensorId = eventVdi.sensorId; 33 event.version = eventVdi.version; 34 event.timestamp = eventVdi.timestamp; 35 event.option = eventVdi.option; 36 event.mode = eventVdi.mode; 37 event.data = eventVdi.data; 38 event.dataLen = eventVdi.dataLen; 39 40 int32_t ret = sensorCallback_->OnDataEvent(event); 41 if (ret != HDF_SUCCESS) { 42 HDF_LOGE("%{public}s OnDataEvent failed, error code is %{public}d", __func__, ret); 43 } 44 45 return ret; 46 } 47 HandleCallbackDeath()48sptr<IRemoteObject> SensorCallbackVdi::HandleCallbackDeath() 49 { 50 sptr<IRemoteObject> remote = OHOS::HDI::hdi_objcast<ISensorCallback>(sensorCallback_); 51 52 return remote; 53 } 54 } // V1_1 55 } // Sensor 56 } // HDI 57 } // OHOS 58