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 "motion_callback_vdi.h"
17 
18 namespace OHOS {
19 namespace HDI {
20 namespace Motion {
21 namespace V1_1 {
22 
OnDataEventVdi(const HdfMotionEventVdi & eventVdi)23 int32_t MotionCallbackVdi::OnDataEventVdi(const HdfMotionEventVdi& eventVdi)
24 {
25     struct HdfMotionEvent event;
26 
27     if (motionCallback_ == nullptr) {
28         HDF_LOGE("%{public}s motionCallback_ is NULL", __func__);
29         return HDF_FAILURE;
30     }
31 
32     event.motion = eventVdi.motion;
33     event.result = eventVdi.result;
34     event.status = eventVdi.status;
35     event.datalen = eventVdi.datalen;
36     event.data = eventVdi.data;
37 
38     int32_t ret = motionCallback_->OnDataEvent(event);
39     if (ret != HDF_SUCCESS) {
40         HDF_LOGE("%{public}s OnDataEvent failed, error code is %{public}d", __func__, ret);
41     }
42 
43     return ret;
44 }
45 
HandleCallbackDeath()46 sptr<IRemoteObject> MotionCallbackVdi::HandleCallbackDeath()
47 {
48     sptr<IRemoteObject> remote = OHOS::HDI::hdi_objcast<IMotionCallback>(motionCallback_);
49 
50     return remote;
51 }
52 } // V1_1
53 } // Motion
54 } // HDI
55 } // OHOS
56