aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-23 10:36:43 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-23 10:36:43 -0700
commit7eb14b383bc7e44add3e1357bbf8010db5a53300 (patch)
treebc07d4d5b8545c44aa9490ca3453ea0f1680c85a /emulator
parentc06b0d531dd14325be08c42850788039cce49ff9 (diff)
parentb7506eb5144551af4137f4cc78feade34aecc7b0 (diff)
downloadsdk-7eb14b383bc7e44add3e1357bbf8010db5a53300.zip
sdk-7eb14b383bc7e44add3e1357bbf8010db5a53300.tar.gz
sdk-7eb14b383bc7e44add3e1357bbf8010db5a53300.tar.bz2
am ceada119: Merge change 2320 into donut
Merge commit 'ceada119d3676a936988cb4b35f75ebf2c28b8ee' * commit 'ceada119d3676a936988cb4b35f75ebf2c28b8ee': Sensors: Use a native_handle for the data channel instead of a single file descriptor.
Diffstat (limited to 'emulator')
-rw-r--r--emulator/sensors/sensors_qemu.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/emulator/sensors/sensors_qemu.c b/emulator/sensors/sensors_qemu.c
index 85a5af4..0cc636a 100644
--- a/emulator/sensors/sensors_qemu.c
+++ b/emulator/sensors/sensors_qemu.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include <string.h>
#include <cutils/log.h>
+#include <cutils/native_handle.h>
#include <cutils/sockets.h>
#include <hardware/sensors.h>
@@ -123,16 +124,19 @@ typedef struct SensorControl {
/* this must return a file descriptor that will be used to read
* the sensors data (it is passed to data__data_open() below
*/
-static int
+static native_handle_t*
control__open_data_source(struct sensors_control_device_t *dev)
{
SensorControl* ctl = (void*)dev;
+ native_handle_t* handle;
if (ctl->fd < 0) {
ctl->fd = qemud_channel_open(SENSORS_SERVICE_NAME);
}
D("%s: fd=%d", __FUNCTION__, ctl->fd);
- return ctl->fd;
+ handle = native_handle_create(1, 0);
+ handle->data[0] = ctl->fd;
+ return handle;
}
static int
@@ -244,7 +248,7 @@ data__now_ns(void)
}
static int
-data__data_open(struct sensors_data_device_t *dev, int fd)
+data__data_open(struct sensors_data_device_t *dev, native_handle_t* handle)
{
SensorData* data = (void*)dev;
int i;
@@ -258,7 +262,9 @@ data__data_open(struct sensors_data_device_t *dev, int fd)
data->timeStart = 0;
data->timeOffset = 0;
- data->events_fd = dup(fd);
+ data->events_fd = dup(handle->data[0]);
+ native_handle_close(handle);
+ native_handle_delete(handle);
return 0;
}