1 /* 2 * Copyright (C) 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 #pragma once 18 #include <vector> 19 #include "data_sink.h" 20 21 namespace goldfish { 22 using ::android::hardware::hidl_bitfield; 23 24 class GnssHwListener { 25 public: 26 explicit GnssHwListener(const DataSink* sink); 27 void reset(); 28 void consume(char); 29 30 private: 31 bool parse(const char* begin, const char* end, const ahg20::ElapsedRealtime&); 32 bool parseGPRMC(const char* begin, const char* end, const ahg20::ElapsedRealtime&); 33 bool parseGPGGA(const char* begin, const char* end, const ahg20::ElapsedRealtime&); 34 35 const DataSink* m_sink; 36 std::vector<char> m_buffer; 37 38 double m_altitude = 0; 39 40 hidl_bitfield<ahg10::GnssLocationFlags> m_flags; 41 }; 42 43 } // namespace goldfish 44