1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FRAME_HANDLER_ULTRASONICS_H
18 #define FRAME_HANDLER_ULTRASONICS_H
19 
20 #include <android/hardware/automotive/evs/1.1/types.h>
21 #include <android/hardware/automotive/evs/1.1/IEvsUltrasonicsArrayStream.h>
22 #include <android/hardware/automotive/evs/1.1/IEvsUltrasonicsArray.h>
23 
24 #include <vector>
25 
26 class FrameHandlerUltrasonics : public
27         android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArrayStream {
28 public:
29     FrameHandlerUltrasonics(
30             android::sp<android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>
31             pEvsUltrasonicsArray);
32 
33     // Implementation for ::android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArrayStream
34     android::hardware::Return<void> notify(
35             const android::hardware::automotive::evs::V1_1::EvsEventDesc& evsEvent) override;
36     android::hardware::Return<void> deliverDataFrame(
37             const android::hardware::automotive::evs::V1_1::UltrasonicsDataFrameDesc&
38              dataFrameDesc) override;
39 
40     bool checkEventReceived(android::hardware::automotive::evs::V1_1::EvsEventDesc evsEvent);
41     int getReceiveFramesCount();
42     bool areAllFramesValid();
43 
44 private:
45     android::sp<android::hardware::automotive::evs::V1_1::IEvsUltrasonicsArray>
46             mEvsUltrasonicsArray;
47     android::hardware::automotive::evs::V1_1::UltrasonicsDataFrameDesc mLastReceivedFrames;
48     std::vector<android::hardware::automotive::evs::V1_1::EvsEventDesc> mReceivedEvents;
49     int mReceiveFramesCount;
50     bool mAllFramesValid = true;
51 };
52 
53 #endif //FRAME_HANDLER_ULTRASONICS_H
54