adb: Prevent registering usb_disconnect twice

adbd can receive multiple AUTH_RSAPUBLICKEY packets. This happens for
example when booting with usb attached when we retry authenticating
after the framework is done booting. Make sure usb_disconnect is only
registered once, otherwise this creates a loop in the disconnects list.

Bug: 8504991
Change-Id: Ia1f9a37005dd17b7eefee1493d622e1679263eea
This commit is contained in:
Benoit Goby 2013-04-01 17:39:06 -07:00
parent d67bbab6d8
commit b66356cab6
1 changed files with 6 additions and 4 deletions

View File

@ -161,7 +161,7 @@ int adb_auth_verify(void *token, void *sig, int siglen)
static void usb_disconnected(void* unused, atransport* t)
{
D("USB disconnect");
D("USB disconnect\n");
remove_transport_disconnect(usb_transport, &usb_disconnect);
usb_transport = NULL;
needs_retry = false;
@ -175,7 +175,7 @@ static void adb_auth_event(int fd, unsigned events, void *data)
if (events & FDE_READ) {
ret = unix_read(fd, response, sizeof(response));
if (ret < 0) {
D("Framework disconnect");
D("Framework disconnect\n");
if (usb_transport)
fdevent_remove(&usb_transport->auth_fde);
framework_fd = -1;
@ -192,8 +192,10 @@ void adb_auth_confirm_key(unsigned char *key, size_t len, atransport *t)
char msg[MAX_PAYLOAD];
int ret;
usb_transport = t;
add_transport_disconnect(t, &usb_disconnect);
if (!usb_transport) {
usb_transport = t;
add_transport_disconnect(t, &usb_disconnect);
}
if (framework_fd < 0) {
D("Client not connected\n");