summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2011-06-25 02:54:19 +0200
committerBenoit Goby <benoit@android.com>2011-07-12 21:38:46 +0200
commit7e6067e36cb311b31ef2c436287282270a6accbf (patch)
tree47c0f2decbcd387b34a4dbd10250ff19ecb22481
parentAdd missing commands to recovery init.rc (diff)
downloadandroid_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.tar
android_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.tar.gz
android_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.tar.bz2
android_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.tar.lz
android_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.tar.xz
android_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.tar.zst
android_bootable_recovery-7e6067e36cb311b31ef2c436287282270a6accbf.zip
-rw-r--r--ui.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ui.c b/ui.c
index 0744da4d9..173631926 100644
--- a/ui.c
+++ b/ui.c
@@ -592,17 +592,18 @@ void ui_show_text(int visible)
// Return true if USB is connected.
static int usb_connected() {
- int fd = open("/sys/class/switch/usb_connected/state", O_RDONLY);
+ int fd = open("/sys/class/android_usb/android0/state", O_RDONLY);
if (fd < 0) {
- printf("failed to open /sys/class/switch/usb_connected/state: %s\n",
+ printf("failed to open /sys/class/android_usb/android0/state: %s\n",
strerror(errno));
return 0;
}
char buf;
- int connected = (read(fd, &buf, 1) == 1) && (buf == '1');
+ /* USB is connected if android_usb state is CONNECTED or CONFIGURED */
+ int connected = (read(fd, &buf, 1) == 1) && (buf == 'C');
if (close(fd) < 0) {
- printf("failed to close /sys/class/switch/usb_connected/state: %s\n",
+ printf("failed to close /sys/class/android_usb/android0/state: %s\n",
strerror(errno));
}
return connected;