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 <future> 19 #include <mutex> 20 #include <thread> 21 22 #include <android-base/unique_fd.h> 23 24 #include <aidl/android/hardware/gnss/IGnssCallback.h> 25 26 #include "IDataSink.h" 27 28 namespace aidl { 29 namespace android { 30 namespace hardware { 31 namespace gnss { 32 namespace implementation { 33 34 using ::android::base::unique_fd; 35 36 class GnssHwConn { 37 public: 38 GnssHwConn(IDataSink&); 39 ~GnssHwConn(); 40 41 bool ok() const; 42 43 private: 44 bool sendWorkerThreadCommand(char cmd) const; 45 46 unique_fd mDevFd; // Goldfish GPS QEMU device 47 unique_fd mCallersFd; // a channel to talk to the thread 48 std::thread mThread; 49 }; 50 51 } // namespace implementation 52 } // namespace gnss 53 } // namespace hardware 54 } // namespace android 55 } // namespace aidl 56