• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
47     std::vector<uint8_t> read() override;
48     int write(const std::vector<uint8_t>& data) override;
49 
isOpen()50     inline bool isOpen() override { return mPipeFd > 0; }
51 
52    private:
53     int mPipeFd;
54     std::mutex mPipeWriteLock;
55 };
56 
57 }  // impl
58 
59 }  // namespace V2_0
60 }  // namespace vehicle
61 }  // namespace automotive
62 }  // namespace hardware
63 }  // namespace android
64 
65 #endif  // ANDROID_EMULATORPIPECOMM_PIPECOMM_H
66