diff options
-rwxr-xr-x | camera/QemuClient.cpp | 21 | ||||
-rwxr-xr-x | camera/QemuClient.h | 2 | ||||
-rw-r--r-- | fingerprint/fingerprint.c | 26 | ||||
-rw-r--r-- | gps/gps_qemu.c | 41 | ||||
-rw-r--r-- | lights/lights_qemu.c | 58 | ||||
-rw-r--r-- | opengl/system/OpenglSystemCommon/QemuPipeStream.cpp | 4 | ||||
-rw-r--r-- | power/power_qemu.c | 16 | ||||
-rw-r--r-- | qemu-props/qemu-props.c | 8 | ||||
-rw-r--r-- | sensors/sensors_qemu.c | 25 |
9 files changed, 112 insertions, 89 deletions
diff --git a/camera/QemuClient.cpp b/camera/QemuClient.cpp index 111cbb8..15c9d00 100755 --- a/camera/QemuClient.cpp +++ b/camera/QemuClient.cpp @@ -32,6 +32,10 @@ #define LOGQ(...) (void(0)) #endif // LOG_QUERIES + +#define QEMU_PIPE_DEBUG LOGQ +#include <system/qemu_pipe.h> + namespace android { /**************************************************************************** @@ -224,14 +228,15 @@ status_t QemuClient::connectClient(const char* param) if (param == NULL || *param == '\0') { /* No parameters: connect to the factory service. */ char pipe_name[512]; - snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", mCameraServiceName); + snprintf(pipe_name, sizeof(pipe_name), "pipe:qemud:%s", + mCameraServiceName); mPipeFD = qemu_pipe_open(pipe_name); } else { /* One extra char ':' that separates service name and parameters + six - * characters for 'qemud:'. This is required by qemu pipe protocol. */ + * characters for 'pipe:qemud:'. This is required by pipe protocol. */ char* connection_str = new char[strlen(mCameraServiceName) + strlen(param) + 8]; - sprintf(connection_str, "qemud:%s:%s", mCameraServiceName, param); + sprintf(connection_str, "pipe:qemud:%s:%s", mCameraServiceName, param); mPipeFD = qemu_pipe_open(connection_str); delete[] connection_str; @@ -262,11 +267,7 @@ status_t QemuClient::sendMessage(const void* data, size_t data_size) return EINVAL; } - /* Note that we don't use here qemud_client_send, since with qemu pipes we - * don't need to provide payload size prior to payload when we're writing to - * the pipe. So, we can use simple write, and qemu pipe will take care of the - * rest, calling the receiving end with the number of bytes transferred. */ - const size_t written = qemud_fd_write(mPipeFD, data, data_size); + const size_t written = TEMP_FAILURE_RETRY(write(mPipeFD, data, data_size)); if (written == data_size) { return NO_ERROR; } else { @@ -292,7 +293,7 @@ status_t QemuClient::receiveMessage(void** data, size_t* data_size) * value. Note also, that the string doesn't contain zero-terminator. */ size_t payload_size; char payload_size_str[9]; - int rd_res = qemud_fd_read(mPipeFD, payload_size_str, 8); + int rd_res = TEMP_FAILURE_RETRY(read(mPipeFD, payload_size_str, 8)); if (rd_res != 8) { ALOGE("%s: Unable to obtain payload size: %s", __FUNCTION__, strerror(errno)); @@ -315,7 +316,7 @@ status_t QemuClient::receiveMessage(void** data, size_t* data_size) __FUNCTION__, payload_size); return ENOMEM; } - rd_res = qemud_fd_read(mPipeFD, *data, payload_size); + rd_res = TEMP_FAILURE_RETRY(read(mPipeFD, *data, payload_size)); if (static_cast<size_t>(rd_res) == payload_size) { *data_size = payload_size; return NO_ERROR; diff --git a/camera/QemuClient.h b/camera/QemuClient.h index 1644321..1a36f4b 100755 --- a/camera/QemuClient.h +++ b/camera/QemuClient.h @@ -22,8 +22,6 @@ * in the emulator via qemu pipe. */ -#include <hardware/qemud.h> - namespace android { /**************************************************************************** diff --git a/fingerprint/fingerprint.c b/fingerprint/fingerprint.c index 6405e26..278b431 100644 --- a/fingerprint/fingerprint.c +++ b/fingerprint/fingerprint.c @@ -27,19 +27,22 @@ */ #define LOG_TAG "FingerprintHal" +#include <cutils/log.h> +#include <hardware/hardware.h> +#include <hardware/fingerprint.h> +#include <system/qemu_pipe.h> + #include <errno.h> #include <endian.h> #include <inttypes.h> #include <malloc.h> +#include <poll.h> +#include <stdbool.h> +#include <stdlib.h> #include <string.h> -#include <cutils/log.h> -#include <hardware/hardware.h> -#include <hardware/fingerprint.h> -#include <hardware/qemud.h> -#include <poll.h> -#define FINGERPRINT_LISTEN_SERVICE_NAME "fingerprintlisten" +#define FINGERPRINT_LISTEN_SERVICE_NAME "pipe:qemud:fingerprintlisten" #define FINGERPRINT_FILENAME "emufp.bin" #define AUTHENTICATOR_ID_FILENAME "emuauthid.bin" #define MAX_COMM_CHARS 128 @@ -659,7 +662,7 @@ static void* listenerFunction(void* data) { qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)data; pthread_mutex_lock(&qdev->lock); - qdev->qchanfd = qemud_channel_open(FINGERPRINT_LISTEN_SERVICE_NAME); + qdev->qchanfd = qemu_pipe_open(FINGERPRINT_LISTEN_SERVICE_NAME); if (qdev->qchanfd < 0) { ALOGE("listener cannot open fingerprint listener service exit"); pthread_mutex_unlock(&qdev->lock); @@ -668,8 +671,9 @@ static void* listenerFunction(void* data) { qdev->listener.state = STATE_IDLE; pthread_mutex_unlock(&qdev->lock); - const char* cmd = "listen"; - if (qemud_channel_send(qdev->qchanfd, cmd, strlen(cmd)) < 0) { + static const char kListenCmd[] = "listen"; + size_t kListenCmdSize = sizeof(kListenCmd) - 1U; + if (qemu_pipe_frame_send(qdev->qchanfd, kListenCmd, kListenCmdSize) < 0) { ALOGE("cannot write fingerprint 'listen' to host"); goto done_quiet; } @@ -724,8 +728,8 @@ static void* listenerFunction(void* data) { } // Shouldn't block since we were just notified of a POLLIN event - if ((size = qemud_channel_recv(qdev->qchanfd, buffer, - sizeof(buffer) - 1)) > 0) { + if ((size = qemu_pipe_frame_recv(qdev->qchanfd, buffer, + sizeof(buffer) - 1)) > 0) { buffer[size] = '\0'; if (sscanf(buffer, "on:%d", &fid) == 1) { if (fid > 0 && fid <= MAX_FID_VALUE) { diff --git a/gps/gps_qemu.c b/gps/gps_qemu.c index 133cbe4..1522c6d 100644 --- a/gps/gps_qemu.c +++ b/gps/gps_qemu.c @@ -34,10 +34,10 @@ #include <cutils/log.h> #include <cutils/sockets.h> #include <hardware/gps.h> -#include <hardware/qemud.h> +#include <system/qemu_pipe.h> -/* the name of the qemud-controlled socket */ -#define QEMU_CHANNEL_NAME "gps" +/* the name of the qemu-controlled pipe */ +#define QEMU_CHANNEL_NAME "pipe:qemud:gps" #define GPS_DEBUG 0 @@ -356,9 +356,9 @@ nmea_reader_update_latlong( NmeaReader* r, static int -nmea_reader_update_altitude( NmeaReader* r, - Token altitude, - Token units ) +nmea_reader_update_altitude( NmeaReader* r, + Token altitude, + Token __unused units ) { double alt; Token tok = altitude; @@ -777,14 +777,14 @@ gps_state_init( GpsState* state, GpsCallbacks* callbacks ) state->control[1] = -1; state->fd = -1; - state->fd = qemud_channel_open(QEMU_CHANNEL_NAME); + state->fd = qemu_pipe_open(QEMU_CHANNEL_NAME); if (state->fd < 0) { D("no gps emulation detected"); return; } - D("gps emulation will read from '%s' qemud channel", QEMU_CHANNEL_NAME ); + D("gps emulation will read from '%s' qemu pipe", QEMU_CHANNEL_NAME ); if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) { ALOGE("could not create thread control socket pair: %s", strerror(errno)); @@ -874,30 +874,38 @@ qemu_gps_stop() static int -qemu_gps_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) +qemu_gps_inject_time(GpsUtcTime __unused time, + int64_t __unused timeReference, + int __unused uncertainty) { return 0; } static int -qemu_gps_inject_location(double latitude, double longitude, float accuracy) +qemu_gps_inject_location(double __unused latitude, + double __unused longitude, + float __unused accuracy) { return 0; } static void -qemu_gps_delete_aiding_data(GpsAidingData flags) +qemu_gps_delete_aiding_data(GpsAidingData __unused flags) { } -static int qemu_gps_set_position_mode(GpsPositionMode mode, int fix_frequency) +static int qemu_gps_set_position_mode(GpsPositionMode __unused mode, + GpsPositionRecurrence __unused recurrence, + uint32_t __unused min_interval, + uint32_t __unused preferred_accuracy, + uint32_t __unused preferred_time) { // FIXME - support fix_frequency return 0; } static const void* -qemu_gps_get_extension(const char* name) +qemu_gps_get_extension(const char* __unused name) { // no extensions supported return NULL; @@ -916,13 +924,14 @@ static const GpsInterface qemuGpsInterface = { qemu_gps_get_extension, }; -const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev) +const GpsInterface* gps__get_gps_interface(struct gps_device_t* __unused dev) { return &qemuGpsInterface; } -static int open_gps(const struct hw_module_t* module, char const* name, - struct hw_device_t** device) +static int open_gps(const struct hw_module_t* module, + char const* __unused name, + struct hw_device_t** device) { struct gps_device_t *dev = malloc(sizeof(struct gps_device_t)); memset(dev, 0, sizeof(*dev)); diff --git a/lights/lights_qemu.c b/lights/lights_qemu.c index 94fe8cc..3628588 100644 --- a/lights/lights_qemu.c +++ b/lights/lights_qemu.c @@ -26,21 +26,6 @@ #define LOG_TAG "Lights" #endif -/* we connect with the emulator through the "hw-control" qemud service */ -#define LIGHTS_SERVICE_NAME "hw-control" - -#include <cutils/log.h> -#include <stdint.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> -#include <fcntl.h> -#include <pthread.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <hardware/lights.h> -#include <hardware/qemud.h> - /* Set to 1 to enable debug messages to the log */ #define DEBUG 0 #if DEBUG @@ -51,6 +36,26 @@ #define E(...) ALOGE(__VA_ARGS__) +/* we connect with the emulator through the "hw-control" qemud service */ +#define LIGHTS_SERVICE_NAME "pipe:qemud:hw-control" + +#include <cutils/log.h> + +#define DEBUG_QEMU_PIPE D +#include <system/qemu_pipe.h> + +#include <hardware/lights.h> +#include <errno.h> +#include <fcntl.h> +#include <pthread.h> +#include <stdint.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <unistd.h> + +#include <stdlib.h> + /* Get brightness(0~255) from state. */ static int rgb_to_brightness( struct light_state_t const* state ) @@ -62,13 +67,13 @@ rgb_to_brightness( struct light_state_t const* state ) /* set backlight brightness by LIGHTS_SERVICE_NAME service. */ static int -set_light_backlight( struct light_device_t* dev, struct light_state_t const* state ) +set_light_backlight( struct light_device_t* __unused dev, struct light_state_t const* state ) { /* Get Lights service. */ - int fd = qemud_channel_open( LIGHTS_SERVICE_NAME ); + int fd = qemu_pipe_open(LIGHTS_SERVICE_NAME); if (fd < 0) { - E( "%s: no qemud connection", __FUNCTION__ ); + E( "%s: no qemu pipe connection", __FUNCTION__ ); return -1; } @@ -87,7 +92,7 @@ set_light_backlight( struct light_device_t* dev, struct light_state_t const* sta D( "%s: lcd_backlight command: %s", __FUNCTION__, buffer ); /* send backlight command to perform the backlight setting. */ - if (qemud_channel_send( fd, buffer, -1 ) < 0) { + if (qemu_pipe_frame_send(fd, buffer, strlen(buffer)) < 0) { E( "%s: could not query lcd_backlight: %s", __FUNCTION__, strerror(errno) ); close( fd ); return -1; @@ -98,7 +103,8 @@ set_light_backlight( struct light_device_t* dev, struct light_state_t const* sta } static int -set_light_buttons( struct light_device_t* dev, struct light_state_t const* state ) +set_light_buttons( struct light_device_t* __unused dev, + struct light_state_t const* __unused state ) { /* @Waiting for later implementation. */ D( "%s: Not implemented.", __FUNCTION__ ); @@ -107,7 +113,8 @@ set_light_buttons( struct light_device_t* dev, struct light_state_t const* state } static int -set_light_battery( struct light_device_t* dev, struct light_state_t const* state ) +set_light_battery( struct light_device_t* __unused dev, + struct light_state_t const* __unused state ) { /* @Waiting for later implementation. */ D( "%s: Not implemented.", __FUNCTION__ ); @@ -116,7 +123,8 @@ set_light_battery( struct light_device_t* dev, struct light_state_t const* state } static int -set_light_keyboard( struct light_device_t* dev, struct light_state_t const* state ) +set_light_keyboard( struct light_device_t* __unused dev, + struct light_state_t const* __unused state ) { /* @Waiting for later implementation. */ D( "%s: Not implemented.", __FUNCTION__ ); @@ -125,7 +133,8 @@ set_light_keyboard( struct light_device_t* dev, struct light_state_t const* stat } static int -set_light_notifications( struct light_device_t* dev, struct light_state_t const* state ) +set_light_notifications( struct light_device_t* __unused dev, + struct light_state_t const* __unused state ) { /* @Waiting for later implementation. */ D( "%s: Not implemented.", __FUNCTION__ ); @@ -134,7 +143,8 @@ set_light_notifications( struct light_device_t* dev, struct light_state_t const* } static int -set_light_attention( struct light_device_t* dev, struct light_state_t const* state ) +set_light_attention( struct light_device_t* __unused dev, + struct light_state_t const* __unused state ) { /* @Waiting for later implementation. */ D( "%s: Not implemented.", __FUNCTION__ ); diff --git a/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp b/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp index 581aec3..bff9794 100644 --- a/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp +++ b/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ #include "QemuPipeStream.h" -#include <hardware/qemu_pipe.h> +#include <system/qemu_pipe.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -51,7 +51,7 @@ QemuPipeStream::~QemuPipeStream() int QemuPipeStream::connect(void) { - m_sock = qemu_pipe_open("opengles"); + m_sock = qemu_pipe_open("pipe:opengles"); if (!valid()) return -1; return 0; } diff --git a/power/power_qemu.c b/power/power_qemu.c index d4251e0..86c3ffd 100644 --- a/power/power_qemu.c +++ b/power/power_qemu.c @@ -19,27 +19,27 @@ #include <hardware/hardware.h> #include <hardware/power.h> -#include <hardware/qemud.h> +#include <system/qemu_pipe.h> #include <fcntl.h> #include <errno.h> static int qemud_fd; -static void power_qemu_init(struct power_module *module) +static void power_qemu_init(struct power_module * __unused module) { - qemud_fd = qemud_channel_open("hw-control"); + qemud_fd = qemu_pipe_open("pipe:qemud:hw-control"); if (qemud_fd < 0) ALOGE("Error connecting to qemud hw-control service\n"); } -static void power_qemu_set_interactive(struct power_module *module, int on) +static void power_qemu_set_interactive(struct power_module * __unused module, + int on) { - int r; - - r = qemud_channel_send(qemud_fd, on ? "power:screen_state:wake" - : "power:screen_state:standby", -1); + const char* command = on ? "power:screen_state:wake" : + "power:screen_state:standby"; + int r = qemu_pipe_frame_send(qemud_fd, command, strlen(command)); if (r < 0) ALOGE("Error sending power command to qemud hw-control service\n"); } diff --git a/qemu-props/qemu-props.c b/qemu-props/qemu-props.c index 56d510f..0b3ea11 100644 --- a/qemu-props/qemu-props.c +++ b/qemu-props/qemu-props.c @@ -34,8 +34,8 @@ #endif #include <cutils/properties.h> +#include <system/qemu_pipe.h> #include <unistd.h> -#include <hardware/qemud.h> /* Name of the qemud service we want to connect to. */ @@ -52,7 +52,7 @@ int main(void) int tries = MAX_TRIES; while (1) { - qemud_fd = qemud_channel_open( "boot-properties" ); + qemud_fd = qemu_pipe_open( "pipe:qemud:boot-properties" ); if (qemud_fd >= 0) break; @@ -69,7 +69,7 @@ int main(void) DD("connected to '%s' qemud service.", QEMUD_SERVICE); /* send the 'list' command to the service */ - if (qemud_channel_send(qemud_fd, "list", -1) < 0) { + if (qemu_pipe_frame_send(qemud_fd, "list", 4) < 0) { DD("could not send command to '%s' service", QEMUD_SERVICE); return 1; } @@ -83,7 +83,7 @@ int main(void) DD("receiving.."); char* q; char temp[BUFF_SIZE]; - int len = qemud_channel_recv(qemud_fd, temp, sizeof temp - 1); + int len = qemu_pipe_frame_recv(qemud_fd, temp, sizeof temp - 1); /* lone NUL-byte signals end of properties */ if (len < 0 || len > BUFF_SIZE-1 || temp[0] == '\0') diff --git a/sensors/sensors_qemu.c b/sensors/sensors_qemu.c index b0e858c..7175a44 100644 --- a/sensors/sensors_qemu.c +++ b/sensors/sensors_qemu.c @@ -23,9 +23,9 @@ */ -/* we connect with the emulator through the "sensors" qemud service +/* we connect with the emulator through the "sensors" qemu pipe service */ -#define SENSORS_SERVICE_NAME "sensors" +#define SENSORS_SERVICE_NAME "pipe:qemud:sensors" #define LOG_TAG "QemuSensors" @@ -45,7 +45,7 @@ #define E(...) ALOGE(__VA_ARGS__) -#include <hardware/qemud.h> +#include <system/qemu_pipe.h> /** SENSOR IDS AND NAMES **/ @@ -152,9 +152,9 @@ typedef struct SensorDevice { * from different threads, and poll() is blocking. * * Note that the emulator's sensors service creates a new client for each - * connection through qemud_channel_open(), where each client has its own + * connection through qemu_pipe_open(), where each client has its own * delay and set of activated sensors. This precludes calling - * qemud_channel_open() on each request, because a typical emulated system + * qemu_pipe_open() on each request, because a typical emulated system * will do something like: * * 1) On a first thread, de-activate() all sensors first, then call poll(), @@ -174,7 +174,7 @@ typedef struct SensorDevice { static int sensor_device_get_fd_locked(SensorDevice* dev) { /* Create connection to service on first call */ if (dev->fd < 0) { - dev->fd = qemud_channel_open(SENSORS_SERVICE_NAME); + dev->fd = qemu_pipe_open(SENSORS_SERVICE_NAME); if (dev->fd < 0) { int ret = -errno; E("%s: Could not open connection to service: %s", __FUNCTION__, @@ -196,7 +196,7 @@ static int sensor_device_send_command_locked(SensorDevice* dev, } int ret = 0; - if (qemud_channel_send(fd, cmd, strlen(cmd)) < 0) { + if (qemu_pipe_frame_send(fd, cmd, strlen(cmd)) < 0) { ret = -errno; E("%s(fd=%d): ERROR: %s", __FUNCTION__, fd, strerror(errno)); } @@ -267,7 +267,7 @@ static int sensor_device_poll_event_locked(SensorDevice* dev) /* read the next event */ char buff[256]; - int len = qemud_channel_recv(fd, buff, sizeof(buff) - 1U); + int len = qemu_pipe_frame_recv(fd, buff, sizeof(buff) - 1U); /* re-acquire the lock to modify the device state. */ pthread_mutex_lock(&dev->lock); @@ -657,22 +657,23 @@ static struct sensor_t sSensorList[MAX_NUM_SENSORS]; static int sensors__get_sensors_list(struct sensors_module_t* module __unused, struct sensor_t const** list) { - int fd = qemud_channel_open(SENSORS_SERVICE_NAME); + int fd = qemu_pipe_open(SENSORS_SERVICE_NAME); char buffer[12]; int mask, nn, count; int ret = 0; if (fd < 0) { - E("%s: no qemud connection", __FUNCTION__); + E("%s: no qemu pipe connection", __FUNCTION__); goto out; } - ret = qemud_channel_send(fd, "list-sensors", -1); + static const char kListSensors[] = "list-sensors"; + ret = qemu_pipe_frame_send(fd, kListSensors, sizeof(kListSensors) - 1); if (ret < 0) { E("%s: could not query sensor list: %s", __FUNCTION__, strerror(errno)); goto out; } - ret = qemud_channel_recv(fd, buffer, sizeof buffer-1); + ret = qemu_pipe_frame_recv(fd, buffer, sizeof buffer-1); if (ret < 0) { E("%s: could not receive sensor list: %s", __FUNCTION__, strerror(errno)); |