1 /* 2 * Copyright (C) 2017 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 ANDROID_EMULATORPIPECOMM_PIPECOMM_H 18 #define ANDROID_EMULATORPIPECOMM_PIPECOMM_H 19 20 #include <mutex> 21 #include <vector> 22 23 #include "CommConn.h" 24 25 namespace android { 26 namespace hardware { 27 namespace automotive { 28 namespace vehicle { 29 namespace V2_0 { 30 31 namespace impl { 32 33 /** 34 * PipeComm opens a qemu pipe to connect to the emulator, allowing the emulator UI to access the 35 * Vehicle HAL and simulate changing properties. 36 * 37 * Since the pipe is a client, it directly implements CommConn, and only one PipeComm can be open 38 * at a time. 39 */ 40 class PipeComm : public CommConn { 41 public: 42 PipeComm(MessageProcessor* messageProcessor); 43 44 void start() override; 45 void stop() override; 46 isOpen()47 inline bool isOpen() override { return mPipeFd > 0; } 48 49 private: 50 int mPipeFd; 51 52 std::vector<uint8_t> read() override; 53 int write(const std::vector<uint8_t>& data) override; 54 }; 55 56 } // namespace impl 57 58 } // namespace V2_0 59 } // namespace vehicle 60 } // namespace automotive 61 } // namespace hardware 62 } // namespace android 63 64 #endif // ANDROID_EMULATORPIPECOMM_PIPECOMM_H 65