Fixed the bug that transport with same serial are multiple generation.
authorKim Gunsoo <gunsoo83.kim@samsung.com>
Tue, 18 Oct 2016 07:18:17 +0000 (16:18 +0900)
committerKim Gunsoo <gunsoo83.kim@samsung.com>
Tue, 18 Oct 2016 07:18:17 +0000 (16:18 +0900)
- There was a bug in the code that checks whether the transport
  with the same serial name, was solved.

Change-Id: I8418c88f7751495d02434586b22bc1e16c28a751
Signed-off-by: Kim Gunsoo <gunsoo83.kim@samsung.com>
src/command_function.c
src/sockets.c
src/transport.c

index b7c8845ec54afa9d7ad111dcc7e534ee6f5ce352..bf8670e2ff0adecd76a9c731daad3c08f3906fb3 100644 (file)
@@ -339,6 +339,9 @@ int __connect(int argc, char ** argv) {
                 if(!strcmp(tmp, STATE_DEVICE) || !strcmp(tmp, STATE_LOCKED) || !strcmp(tmp, STATE_SUSPENDED)) {
                     printf("connected to %s\n", remote_target_info);
                     return 0;
+                } else if (!strcmp(tmp, STATE_UNAUTHORIZED)) {
+                    printf("device unauthorized. Please approve on your device.\n");
+                    return 1;
                 }
             } else {
                 // connection error occurred
index d8428e0effc7ecb6e6c7d25d2327f21afe18cb77..68e14d2e313a69af86aa71a336f745ea98e133d1 100755 (executable)
@@ -31,6 +31,7 @@
 #include "listener.h"
 #include "sdb.h"
 #include "sdb_messages.h"
+#include "adb_auth.h"
 
 #define  TRACE_TAG  TRACE_SOCKETS
 
@@ -1323,6 +1324,16 @@ static int smart_socket_enqueue(SDB_SOCKET *s, PACKET *p)
             s->transport = t;
             sdb_write(s->fd, "OKAY", 4);
             D("LS(%X) get transport T(%s)", s->local_id, t->serial);
+        } else if (t && t->connection_state == CS_UNAUTHORIZED) {
+            if (t->target_type == TARGET_NO_SCREEN) {
+                err_str = MSG_UNAUTHORIZE_NO_SCREEN;
+            } else {
+                err_str = MSG_UNAUTHORIZE;
+            }
+
+            LOG_ERROR("LS(%X) transport is unauthorized.", s->local_id);
+            sendfailmsg(s->fd, err_str);
+            goto fail;
         } else {
             if(t != NULL) {
                 if(t->suspended) {
index 5a1a83b7684ce73e41bd6f2736ee6bf84b61eff1..672786fc27deea1bbfe11504a407092b2f1fad21 100755 (executable)
@@ -619,17 +619,6 @@ TRANSPORT *acquire_one_transport(transport_type ttype, const char* serial, char*
 
     if (result == NULL ) {
         *error_out = error_message(SDB_MESSAGE_ERROR, ERR_CONNECT_TARGET_NOT_FOUND, NULL);
-    } else {
-        if (result->connection_state == CS_UNAUTHORIZED) {
-            if (error_out)  {
-                if(result->target_type == TARGET_NO_SCREEN)
-                    *error_out = MSG_UNAUTHORIZE_NO_SCREEN;
-                else
-                    *error_out = MSG_UNAUTHORIZE;
-            }
-            result = NULL;
-            goto exit;
-        }
     }
 
 exit: