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 <condition_variable> 19 #include <mutex> 20 #include <thread> 21 #include <aidl/android/hardware/gnss/BnGnssMeasurementInterface.h> 22 23 namespace aidl { 24 namespace android { 25 namespace hardware { 26 namespace gnss { 27 namespace implementation { 28 29 struct GnssMeasurementInterface : public BnGnssMeasurementInterface { 30 GnssMeasurementInterface() = default; 31 ~GnssMeasurementInterface(); 32 33 ndk::ScopedAStatus setCallback(const std::shared_ptr<IGnssMeasurementCallback>& callback, 34 const bool enableFullTracking, 35 const bool enableCorrVecOutputs) override; 36 ndk::ScopedAStatus close() override; 37 ndk::ScopedAStatus setCallbackWithOptions( 38 const std::shared_ptr<IGnssMeasurementCallback>& callback, 39 const Options& options) override; 40 41 private: 42 void closeImpl(); 43 ndk::ScopedAStatus setCallbackImpl(const std::shared_ptr<IGnssMeasurementCallback>& callback, 44 bool enableCorrVecOutputs, 45 int intervalMs); 46 void stopLocked(); 47 void update(); 48 49 std::shared_ptr<IGnssMeasurementCallback> mCallback; 50 std::vector<GnssData> mGnssData; 51 int mGnssDataIndex = 0; 52 std::condition_variable mThreadNotification; 53 bool mRunning = false; 54 std::thread mThread; 55 mutable std::mutex mMtx; 56 }; 57 58 } // namespace implementation 59 } // namespace gnss 60 } // namespace hardware 61 } // namespace android 62 } // namespace aidl 63