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 <android/hardware/gnss/2.0/IGnss.h> 19 #include <chrono> 20 #include <mutex> 21 22 namespace goldfish { 23 namespace ahg = ::android::hardware::gnss; 24 namespace ahg20 = ahg::V2_0; 25 namespace ahg10 = ahg::V1_0; 26 27 using ::android::sp; 28 using ::android::hardware::hidl_string; 29 using ::android::hardware::hidl_vec; 30 31 class DataSink { 32 public: 33 void gnssLocation(const ahg20::GnssLocation&) const; 34 void gnssSvStatus(const hidl_vec<ahg20::IGnssCallback::GnssSvInfo>&) const; 35 void gnssStatus(const ahg10::IGnssCallback::GnssStatusValue) const; 36 void gnssNmea(const ahg10::GnssUtcTime, const hidl_string&) const; 37 38 void setCallback20(sp<ahg20::IGnssCallback>); 39 void start(); 40 void cleanup(); 41 42 private: 43 bool isWarmedUd() const; 44 45 sp<ahg20::IGnssCallback> cb20; 46 std::chrono::steady_clock::time_point warmedUpTime; 47 mutable std::mutex mtx; 48 }; 49 50 } // namespace goldfish 51