diff options
author | Benoit Goby <benoit@android.com> | 2011-07-13 00:39:11 +0200 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-13 00:39:11 +0200 |
commit | 8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f (patch) | |
tree | e357f161fcee92785bcda0a2781404d0efa1c391 | |
parent | Remove the simulator target from all makefiles. (diff) | |
parent | Update usb_connected() to support new gadget driver (diff) | |
download | android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.tar android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.tar.gz android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.tar.bz2 android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.tar.lz android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.tar.xz android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.tar.zst android_bootable_recovery-8d92ae052e3b244f8a1e5c36ecae1c7268f82a9f.zip |
-rw-r--r-- | ui.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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; |