Android-x86
Fork

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-libhardware_legacy: コミット

hardware/libhardware_legacy


コミットメタ情報

リビジョンabaadf73a716ab83c0b494cb662db0ea68840ee6 (tree)
日時2009-03-28 07:31:11
作者The Android Open Source Project <initial-contribution@andr...>
コミッターThe Android Open Source Project

ログメッセージ

Merge commit 'korg/cupcake'

変更サマリ

差分

--- a/include/hardware_legacy/gps.h
+++ b/include/hardware_legacy/gps.h
@@ -241,6 +241,18 @@ typedef struct {
241241 int (*inject_xtra_data)( char* data, int length );
242242 } GpsXtraInterface;
243243
244+/** Extended interface for SUPL support. */
245+typedef struct {
246+ /**
247+ * Sets the name of the APN to be used for SUPL.
248+ */
249+ int (*set_apn)( const char* apn );
250+ /**
251+ * Sets the IP address and port for the SUPL server.
252+ */
253+ int (*set_server)( uint32_t addr, int port );
254+} GpsSuplInterface;
255+
244256 /** Returns the hardware GPS interface. */
245257 const GpsInterface* gps_get_hardware_interface();
246258
--- a/include/hardware_legacy/led.h
+++ /dev/null
@@ -1,44 +0,0 @@
1-/*
2- * Copyright (C) 2008 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 _HARDWARE_LED_H
18-#define _HARDWARE_LED_H
19-
20-#if __cplusplus
21-extern "C" {
22-#endif
23-
24-/**
25- * Changes the state of the LED.
26- *
27- * -# Turn on LED: Alpha != 0 and RBG != 0, onMS == 0 && offMS == 0.
28- * -# Blink LED: Alpha != 0 and RBG != 0, onMS != 0 && offMS != 0.
29- * -# Turn off LED: Alpha == 0 or RGB == 0.
30- *
31- * @param colorARGB represents the LED's color: Alpha=31:24, Red=23:16
32- * Green=15:8 Blue=7:0
33- * @param onMS represents the time the LED is on in milliseconds
34- * @param offMS represents the time the LED is off in milliseconds
35- *
36- * @return 0 if successful
37- */
38-int set_led_state(unsigned colorARGB, int onMS, int offMS);
39-
40-#if __cplusplus
41-} // extern "C"
42-#endif
43-
44-#endif // _HARDWARE_LED_H
--- a/include/hardware_legacy/power.h
+++ b/include/hardware_legacy/power.h
@@ -33,19 +33,6 @@ enum {
3333 int acquire_wake_lock(int lock, const char* id);
3434 int release_wake_lock(const char* id);
3535
36-
37-enum {
38- KEYBOARD_LIGHT = 0x00000001,
39- SCREEN_LIGHT = 0x00000002,
40- BUTTON_LIGHT = 0x00000004,
41-};
42-
43-// set the lights identified in mask to the brightness specified
44-// in value. for example
45-// set_light_brightness(SCREEN_LIGHT | KEYBOARD_LIGHT, 200);
46-// sets the screen and keyboard lights to brightness 200
47-int set_light_brightness(unsigned int mask, unsigned int brightness);
48-
4936 // true if you want the screen on, false if you want it off
5037 int set_screen_state(int on);
5138
--- a/led/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
1-# Copyright 2006 The Android Open Source Project
2-
3-ifeq ($(TARGET_DEVICE),sooner)
4-LOCAL_SRC_FILES += led/led_sardine.c
5-LOCAL_CFLAGS += -DCONFIG_LED_SARDINE
6-endif
7-ifneq (,$(filter $(TARGET_DEVICE),dream sapphire))
8-LOCAL_SRC_FILES += led/led_trout.c
9-LOCAL_CFLAGS += -DCONFIG_LED_TROUT
10-endif
11-ifeq ($(QEMU_HARDWARE),true)
12-LOCAL_CFLAGS += -DCONFIG_LED_QEMU
13-endif
14-LOCAL_SRC_FILES += led/led_stub.c
15-
--- a/led/led_qemu.c
+++ /dev/null
@@ -1,23 +0,0 @@
1-/*
2- * Copyright (C) 2008 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-#include "qemu.h"
17-
18-int
19-qemu_set_led_state(unsigned color, int on, int off)
20-{
21- qemu_control_command( "set_led_state:%08x:%d:%d", color, on, off );
22- return 0;
23-}
--- a/led/led_sardine.c
+++ /dev/null
@@ -1,78 +0,0 @@
1-/*
2- * Copyright (C) 2008 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-#include <hardware_legacy/led.h>
17-#include <sys/types.h>
18-#include <sys/stat.h>
19-#include <fcntl.h>
20-#include <unistd.h>
21-#include <errno.h>
22-#include <stdio.h>
23-
24-const char* const CADENCE_FILE = "/sys/class/leds/left/cadence";
25-const char* const COLOR_FILE = "/sys/class/leds/left/color";
26-const char* const BT_WIFI_FILE = "/sys/class/leds/right/brightness";
27-
28-static int
29-write_string(const char* file, const char* string, int len)
30-{
31- int fd;
32- ssize_t amt;
33-
34- fd = open(file, O_RDWR);
35- if (fd < 0) {
36- return errno;
37- }
38-
39- amt = write(fd, string, len+1);
40-
41- close(fd);
42- return amt >= 0 ? 0 : errno;
43-}
44-
45-int sardine_set_led_state(unsigned colorARGB, int onMS, int offMS)
46-{
47- int len;
48- char buf[30];
49- int red, green, color;
50-
51- // alpha of 0 or color of 0 (ignoring blue) means off
52- if ((colorARGB & 0xff000000) == 0 || (colorARGB & 0x00ffff00) == 0) {
53- onMS = 0;
54- offMS = 0;
55- }
56-
57- // blue means green
58- if ((colorARGB & 0x00ffff00) == 0 && (colorARGB & 0x000000ff) != 0) {
59- colorARGB |= (colorARGB & 0x000000ff) << 8;
60- }
61-
62- // ===== color =====
63- // this color conversion isn't really correct, but it's better to
64- // have the light come bright on when asked for low intensity than to
65- // not come on at all. we have no blue
66- red = (colorARGB & 0x00ff0000) ? 1 : 0;
67- green = (colorARGB & 0x0000ff00) ? 2 : 0;
68- color = (red | green) - 1;
69-
70- len = sprintf(buf, "%d", color);
71- write_string(COLOR_FILE, buf, len);
72-
73- // ===== color =====
74- len = sprintf(buf, "%d,%d", onMS, offMS);
75- write_string(CADENCE_FILE, buf, len);
76-
77- return 0;
78-}
--- a/led/led_stub.c
+++ /dev/null
@@ -1,51 +0,0 @@
1-/*
2- * Copyright (C) 2008 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-#include <hardware_legacy/led.h>
17-
18-typedef int (*LedFunc)(unsigned, int, int);
19-
20-#ifdef CONFIG_LED_SARDINE
21-extern int sardine_set_led_state(unsigned, int, int);
22-# define HW_LED_FUNC sardine_set_led_state
23-#endif
24-
25-#ifdef CONFIG_LED_TROUT
26-extern int trout_set_led_state(unsigned, int, int);
27-# define HW_LED_FUNC trout_set_led_state
28-#endif
29-
30-#ifdef CONFIG_LED_QEMU
31-#include "qemu.h"
32-static int
33-qemu_set_led_state(unsigned color, int on, int off)
34-{
35- qemu_control_command( "set_led_state:%08x:%d:%d", color, on, off );
36- return 0;
37-}
38-#endif
39-
40-int
41-set_led_state(unsigned color, int on, int off)
42-{
43-#ifdef CONFIG_LED_QEMU
44- QEMU_FALLBACK(set_led_state(color,on,off));
45-#endif
46-#ifdef HW_LED_FUNC
47- return HW_LED_FUNC(color, on, off);
48-#else
49- return 0;
50-#endif
51-}
--- a/led/led_trout.c
+++ /dev/null
@@ -1,115 +0,0 @@
1-/*
2- * Copyright (C) 2008 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-#include <hardware_legacy/led.h>
17-#include <sys/types.h>
18-#include <sys/stat.h>
19-#include <fcntl.h>
20-#include <unistd.h>
21-#include <errno.h>
22-#include <stdio.h>
23-
24-#define LOG_TAG "LED"
25-#include <utils/Log.h>
26-
27-const char* const AMBER_BRIGHTNESS_FILE = "/sys/class/leds/amber/brightness";
28-const char* const RED_BRIGHTNESS_FILE = "/sys/class/leds/red/brightness";
29-const char* const GREEN_BRIGHTNESS_FILE = "/sys/class/leds/green/brightness";
30-const char* const BLUE_BRIGHTNESS_FILE = "/sys/class/leds/blue/brightness";
31-const char* const BLINK_ENABLE_FILE = "/sys/class/leds/red/device/blink";
32-const char* const BLINK_FREQ_FILE = "/sys/class/leds/red/device/grpfreq";
33-const char* const BLINK_PWM_FILE = "/sys/class/leds/red/device/grppwm";
34-
35-static int
36-write_string(const char* file, const char* string, int len)
37-{
38- int fd;
39- ssize_t amt;
40-
41- fd = open(file, O_RDWR);
42- if (fd < 0) {
43- LOGE("open failed errno: %d\n", errno);
44- return errno;
45- }
46-
47- amt = write(fd, string, len);
48- if (amt < 0) {
49- LOGE("write failed errno: %d\n", errno);
50- }
51-
52- close(fd);
53- return amt >= 0 ? 0 : errno;
54-}
55-
56-int trout_set_led_state(unsigned colorARGB, int onMS, int offMS)
57-{
58- int len;
59- char buf[30];
60- int alpha, red, green, blue;
61- int blink, freq, pwm;
62-
63- LOGV("set_led_state colorARGB=%08X, onMS=%d, offMS=%d\n", colorARGB, onMS, offMS);
64-
65- // alpha of 0 or color of 0 means off
66- if ((colorARGB & 0xff000000) == 0 || (colorARGB & 0x00ffffff) == 0) {
67- onMS = 0;
68- offMS = 0;
69- }
70-
71- red = (colorARGB >> 16) & 0xFF;
72- green = (colorARGB >> 8) & 0xFF;
73- blue = colorARGB & 0xFF;
74-
75- len = sprintf(buf, "%d", red);
76- write_string(RED_BRIGHTNESS_FILE, buf, len);
77- len = sprintf(buf, "%d", green);
78- write_string(GREEN_BRIGHTNESS_FILE, buf, len);
79- len = sprintf(buf, "%d", blue);
80- write_string(BLUE_BRIGHTNESS_FILE, buf, len);
81-
82- if (onMS > 0 && offMS > 0) {
83- int totalMS = onMS + offMS;
84-
85- // the LED appears to blink about once per second if freq is 20
86- // 1000ms / 20 = 50
87- freq = totalMS / 50;
88- // pwm specifies the ratio of ON versus OFF
89- // pwm = 0 -> always off
90- // pwm = 255 => always on
91- pwm = (onMS * 255) / totalMS;
92-
93- // the low 4 bits are ignored, so round up if necessary
94- if (pwm > 0 && pwm < 16)
95- pwm = 16;
96-
97- blink = 1;
98- } else {
99- blink = 0;
100- freq = 0;
101- pwm = 0;
102- }
103-
104- if (blink) {
105- len = sprintf(buf, "%d", freq);
106- write_string(BLINK_FREQ_FILE, buf, len);
107- len = sprintf(buf, "%d", pwm);
108- write_string(BLINK_PWM_FILE, buf, len);
109- }
110-
111- len = sprintf(buf, "%d", blink);
112- write_string(BLINK_ENABLE_FILE, buf, len);
113-
114- return 0;
115-}
--- a/power/power.c
+++ b/power/power.c
@@ -56,10 +56,6 @@ const char * const NEW_PATHS[] = {
5656
5757 const char * const AUTO_OFF_TIMEOUT_DEV = "/sys/android_power/auto_off_timeout";
5858
59-const char * const LCD_BACKLIGHT = "/sys/class/leds/lcd-backlight/brightness";
60-const char * const BUTTON_BACKLIGHT = "/sys/class/leds/button-backlight/brightness";
61-const char * const KEYBOARD_BACKLIGHT = "/sys/class/leds/keyboard-backlight/brightness";
62-
6359 //XXX static pthread_once_t g_initialized = THREAD_ONCE_INIT;
6460 static int g_initialized = 0;
6561 static int g_fds[OUR_FD_COUNT];
@@ -162,54 +158,6 @@ set_last_user_activity_timeout(int64_t delay)
162158 }
163159 }
164160
165-static void
166-set_a_light(const char* path, int value)
167-{
168- int fd;
169- static int already_warned = 0;
170-
171- // LOGI("set_a_light(%s, %d)\n", path, value);
172-
173- fd = open(path, O_RDWR);
174- if (fd >= 0) {
175- char buffer[20];
176- int bytes = sprintf(buffer, "%d\n", value);
177- write(fd, buffer, bytes);
178- close(fd);
179- } else {
180- if (already_warned == 0) {
181- LOGE("set_a_light failed to open %s\n", path);
182- already_warned = 1;
183- }
184- }
185-}
186-
187-int
188-set_light_brightness(unsigned int mask, unsigned int brightness)
189-{
190- QEMU_FALLBACK(set_light_brightness(mask,brightness));
191-
192- initialize_fds();
193-
194-// LOGI("set_light_brightness mask=0x%08x brightness=%d now=%lld g_error=%s\n",
195-// mask, brightness, systemTime(), strerror(g_error));
196-
197- if (mask & KEYBOARD_LIGHT) {
198- set_a_light(KEYBOARD_BACKLIGHT, brightness);
199- }
200-
201- if (mask & SCREEN_LIGHT) {
202- set_a_light(LCD_BACKLIGHT, brightness);
203- }
204-
205- if (mask & BUTTON_LIGHT) {
206- set_a_light(BUTTON_BACKLIGHT, brightness);
207- }
208-
209- return 0;
210-}
211-
212-
213161 int
214162 set_screen_state(int on)
215163 {
--- a/power/power_qemu.c
+++ b/power/power_qemu.c
@@ -19,29 +19,6 @@
1919 #include <errno.h>
2020 #include <hardware_legacy/power.h>
2121
22-static void
23-set_a_light(const char* name, unsigned brightness)
24-{
25- qemu_control_command( "power:light:brightness:%s:%d",
26- name, brightness );
27-}
28-
29-int
30-qemu_set_light_brightness(unsigned int mask, unsigned int brightness)
31-{
32- if (mask & KEYBOARD_LIGHT) {
33- set_a_light("keyboard_backlight", brightness);
34- }
35- if (mask & SCREEN_LIGHT) {
36- set_a_light("lcd_backlight", brightness);
37- }
38- if (mask & BUTTON_LIGHT) {
39- set_a_light("button_backlight", brightness);
40- }
41- return 0;
42-}
43-
44-
4522 int
4623 qemu_set_screen_state(int on)
4724 {
--- a/power/power_qemu.h
+++ b/power/power_qemu.h
@@ -19,9 +19,6 @@
1919 #include <stdint.h>
2020
2121 extern int
22-qemu_set_light_brightness(unsigned int mask, unsigned int brightness);
23-
24-extern int
2522 qemu_set_screen_state(int on);
2623
2724 #endif /* _power_qemu_h */
--- a/qemu.h
+++ b/qemu.h
@@ -35,7 +35,9 @@ typedef struct {
3535 char is_inited;
3636 char is_available;
3737 char is_qemud;
38+ char is_qemud_old;
3839 char is_tty;
40+ int fd;
3941 char device[32];
4042 } QemuChannel;
4143
@@ -65,15 +67,15 @@ extern int qemu_command_format( char* buffer,
6567 const char* format,
6668 ... );
6769
68-/* directly sends a command through the 'control' channel.
70+/* directly sends a command through the 'hw-control' channel.
6971 * this will open the channel, send the formatted command, then
7072 * close the channel automatically.
7173 * returns 0 on success, or -1 on error.
7274 */
7375 extern int qemu_control_command( const char* fmt, ... );
7476
75-/* sends a question to the control channel, then receive an answer in
76- * a user-allocated buffer. returns the lenght of the answer, or -1
77+/* sends a question to the hw-control channel, then receive an answer in
78+ * a user-allocated buffer. returns the length of the answer, or -1
7779 * in case of error.
7880 *
7981 * 'question' *must* have been formatted through qemu_command_format
--- a/qemu/qemu.c
+++ b/qemu/qemu.c
@@ -50,6 +50,116 @@ qemu_check(void)
5050 return in_qemu;
5151 }
5252
53+static int
54+qemu_fd_write( int fd, const char* cmd, int len )
55+{
56+ int len2;
57+ do {
58+ len2 = write(fd, cmd, len);
59+ } while (len2 < 0 && errno == EINTR);
60+ return len2;
61+}
62+
63+static int
64+qemu_fd_read( int fd, char* buff, int len )
65+{
66+ int len2;
67+ do {
68+ len2 = read(fd, buff, len);
69+ } while (len2 < 0 && errno == EINTR);
70+ return len2;
71+}
72+
73+
74+static int
75+qemu_channel_open_qemud( QemuChannel* channel,
76+ const char* name )
77+{
78+ int fd, ret, namelen = strlen(name);
79+ char answer[2];
80+
81+ fd = socket_local_client( "qemud",
82+ ANDROID_SOCKET_NAMESPACE_RESERVED,
83+ SOCK_STREAM );
84+ if (fd < 0) {
85+ D("no qemud control socket: %s", strerror(errno));
86+ return -1;
87+ }
88+
89+ /* send service name to connect */
90+ if (qemu_fd_write(fd, name, namelen) != namelen) {
91+ D("can't send service name to qemud: %s",
92+ strerror(errno));
93+ close(fd);
94+ return -1;
95+ }
96+
97+ /* read answer from daemon */
98+ if (qemu_fd_read(fd, answer, 2) != 2 ||
99+ answer[0] != 'O' || answer[1] != 'K') {
100+ D("cant' connect to %s service through qemud", name);
101+ close(fd);
102+ return -1;
103+ }
104+
105+ channel->is_qemud = 1;
106+ channel->fd = fd;
107+ return 0;
108+}
109+
110+
111+static int
112+qemu_channel_open_qemud_old( QemuChannel* channel,
113+ const char* name )
114+{
115+ int fd;
116+
117+ snprintf(channel->device, sizeof channel->device,
118+ "qemud_%s", name);
119+
120+ fd = socket_local_client( channel->device,
121+ ANDROID_SOCKET_NAMESPACE_RESERVED,
122+ SOCK_STREAM );
123+ if (fd < 0) {
124+ D("no '%s' control socket available: %s",
125+ channel->device, strerror(errno));
126+ return -1;
127+ }
128+
129+ close(fd);
130+ channel->is_qemud_old = 1;
131+ return 0;
132+}
133+
134+
135+static int
136+qemu_channel_open_tty( QemuChannel* channel,
137+ const char* name,
138+ int mode )
139+{
140+ char key[PROPERTY_KEY_MAX];
141+ char prop[PROPERTY_VALUE_MAX];
142+ int ret;
143+
144+ ret = snprintf(key, sizeof key, "ro.kernel.android.%s", name);
145+ if (ret >= (int)sizeof key)
146+ return -1;
147+
148+ if (property_get(key, prop, "") == 0) {
149+ D("no kernel-provided %s device name", name);
150+ return -1;
151+ }
152+
153+ ret = snprintf(channel->device, sizeof channel->device,
154+ "/dev/%s", prop);
155+ if (ret >= (int)sizeof channel->device) {
156+ D("%s device name too long: '%s'", name, prop);
157+ return -1;
158+ }
159+
160+ channel->is_tty = !memcmp("/dev/tty", channel->device, 8);
161+ return 0;
162+}
53163
54164 int
55165 qemu_channel_open( QemuChannel* channel,
@@ -61,67 +171,44 @@ qemu_channel_open( QemuChannel* channel,
61171 /* initialize the channel is needed */
62172 if (!channel->is_inited)
63173 {
64- int done = 0;
174+ channel->is_inited = 1;
65175
66- // try to connect to qemud socket first
67176 do {
68- snprintf(channel->device, sizeof channel->device,
69- "qemud_%s", name);
70-
71- fd = socket_local_client( channel->device,
72- ANDROID_SOCKET_NAMESPACE_RESERVED,
73- SOCK_STREAM );
74- if (fd < 0) {
75- D("no '%s' control socket available: %s",
76- channel->device, strerror(errno));
77- break;
78- }
79- close(fd);
80- channel->is_qemud = 1;
81- done = 1;
82- } while (0);
83-
84- // otherwise, look for a kernel-provided device name
85- if (!done) do {
86- char key[PROPERTY_KEY_MAX];
87- char prop[PROPERTY_VALUE_MAX];
88- int ret;
89-
90- ret = snprintf(key, sizeof key, "ro.kernel.android.%s", name);
91- if (ret >= (int)sizeof key)
177+ if (qemu_channel_open_qemud(channel, name) == 0)
92178 break;
93179
94- if (property_get(key, prop, "") == 0) {
95- D("no kernel-provided %s device name", name);
180+ if (qemu_channel_open_qemud_old(channel, name) == 0)
96181 break;
97- }
98182
99- ret = snprintf(channel->device, sizeof channel->device,
100- "/dev/%s", prop);
101- if (ret >= (int)sizeof channel->device) {
102- D("%s device name too long: '%s'", name, prop);
183+ if (qemu_channel_open_tty(channel, name, mode) == 0)
103184 break;
104- }
105- channel->is_tty = !memcmp("/dev/tty", channel->device, 8);
106- done = 1;
107185
186+ channel->is_available = 0;
187+ return -1;
108188 } while (0);
109189
110- channel->is_available = done;
111- channel->is_inited = 1;
190+ channel->is_available = 1;
112191 }
113192
114193 /* try to open the file */
115194 if (!channel->is_available) {
116- fd = -1;
117195 errno = ENOENT;
118- } else if (channel->is_qemud) {
196+ return -1;
197+ }
198+
199+ if (channel->is_qemud) {
200+ return dup(channel->fd);
201+ }
202+
203+ if (channel->is_qemud_old) {
119204 do {
120205 fd = socket_local_client( channel->device,
121206 ANDROID_SOCKET_NAMESPACE_RESERVED,
122207 SOCK_STREAM );
123208 } while (fd < 0 && errno == EINTR);
124- } else {
209+ }
210+ else /* /dev/ttySn ? */
211+ {
125212 do {
126213 fd = open(channel->device, mode);
127214 } while (fd < 0 && errno == EINTR);
@@ -181,7 +268,7 @@ qemu_control_fd(void)
181268 static QemuChannel channel[1];
182269 int fd;
183270
184- fd = qemu_channel_open( channel, "control", O_RDWR );
271+ fd = qemu_channel_open( channel, "hw-control", O_RDWR );
185272 if (fd < 0) {
186273 D("%s: could not open control channel: %s", __FUNCTION__,
187274 strerror(errno));
@@ -190,26 +277,6 @@ qemu_control_fd(void)
190277 }
191278
192279 static int
193-qemu_control_write( int fd, const char* cmd, int len )
194-{
195- int len2;
196- do {
197- len2 = write(fd, cmd, len);
198- } while (len2 < 0 && errno == EINTR);
199- return len2;
200-}
201-
202-static int
203-qemu_control_read( int fd, char* buff, int len )
204-{
205- int len2;
206- do {
207- len2 = read(fd, buff, len);
208- } while (len2 < 0 && errno == EINTR);
209- return len2;
210-}
211-
212-static int
213280 qemu_control_send(const char* cmd, int len)
214281 {
215282 int fd, len2;
@@ -223,7 +290,7 @@ qemu_control_send(const char* cmd, int len)
223290 if (fd < 0)
224291 return -1;
225292
226- len2 = qemu_control_write(fd, cmd, len);
293+ len2 = qemu_fd_write(fd, cmd, len);
227294 close(fd);
228295 if (len2 != len) {
229296 D("%s: could not send everything %d < %d",
@@ -273,7 +340,7 @@ extern int qemu_control_query( const char* question, int questionlen,
273340 if (fd < 0)
274341 return -1;
275342
276- ret = qemu_control_write( fd, question, questionlen );
343+ ret = qemu_fd_write( fd, question, questionlen );
277344 if (ret != questionlen) {
278345 D("%s: could not write all: %d < %d", __FUNCTION__,
279346 ret, questionlen);
@@ -281,14 +348,14 @@ extern int qemu_control_query( const char* question, int questionlen,
281348 }
282349
283350 /* read a 4-byte header giving the length of the following content */
284- ret = qemu_control_read( fd, header, 4 );
351+ ret = qemu_fd_read( fd, header, 4 );
285352 if (ret != 4) {
286353 D("%s: could not read header (%d != 4)",
287354 __FUNCTION__, ret);
288355 goto Exit;
289356 }
290357
291- header[5] = 0;
358+ header[4] = 0;
292359 len = strtol( header, &end, 16 );
293360 if ( len < 0 || end == NULL || end != header+4 || len > answersize ) {
294361 D("%s: could not parse header: '%s'",
@@ -297,7 +364,7 @@ extern int qemu_control_query( const char* question, int questionlen,
297364 }
298365
299366 /* read the answer */
300- ret = qemu_control_read( fd, answer, len );
367+ ret = qemu_fd_read( fd, answer, len );
301368 if (ret != len) {
302369 D("%s: could not read all of answer %d < %d",
303370 __FUNCTION__, ret, len);
旧リポジトリブラウザで表示