Hi, Michael,

On Sun, Nov 2, 2014 at 7:29 PM, Michael Albinus <[email protected]>
wrote:

> Ashi <[email protected]> writes:
>
> Hi Zhongwei,
>
> > But it failed at the tramp-test26-process-file test.
>
> There was an error indeed in `tramp-adb-handle-process-file', I've fixed
> that in the repository.
>

Thanks!  All tests can be passed now. And the updated patch (changes in
tramp-test22-file-times test case) is attached.


> However, when I apply your patch, I'm not able to open
> "/adb:3335F075A13600EC#5555:". Maybe it is because "adb devices" does
> not show the port numbers in my case?
>
> # adb devices
> List of devices attached
> 3335F075A13600EC        device
>

adb has 2 kinds of connection:

- connected by USB, and adb devices will list a serial No., like in your
case:
  3335F075A13600EC        device

- connected by TCPIP, and adb devices will list IP address + PORT, e.g.:
  10.164.2.162:5555    device

  you can switch to this by running "adb tcpip" if your device have a
network interface, and then run "adb connect IP_ADDRESS" to connect to your
device. There are more details in this page:
http://developer.android.com/tools/help/adb.html#wireless

So in your case, there is no need to add port number in the path. It should
be "/adb:3335F075A13600EC:". The port number is only needed when connected
by TCPIP.

Best regards,
Zhongwei

>
> Best regards, Michael.
>
From cd64f8fc06f5c8d563bc6ea1d10152a4adffb181 Mon Sep 17 00:00:00 2001
From: Zhongwei Yao <[email protected]>
Date: Wed, 24 Sep 2014 17:38:39 +0800
Subject: [PATCH] enable adb access with port format, e.g.
 /adb:164.2.168.1#5555:/

---
 lisp/tramp-adb.el   | 18 ++++++++++++++----
 test/tramp-tests.el |  3 ++-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/lisp/tramp-adb.el b/lisp/tramp-adb.el
index 8199b39..002b322 100644
--- a/lisp/tramp-adb.el
+++ b/lisp/tramp-adb.el
@@ -990,11 +990,20 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
 	  (tramp-set-connection-property v "process-buffer" nil))))))
 
 ;; Helper functions.
+(defun tramp-adb-get-host-for-execution (vec)
+  "Returns host name and port from VEC to be used in shell exceution.
+E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
+     a host name \"R38273882DE\" returns \"R38273882DE\"."
+  (if (tramp-file-name-port vec)
+      (format
+       "%s:%s" (tramp-file-name-real-host vec) (tramp-file-name-port vec))
+    (tramp-file-name-host vec)))
 
 (defun tramp-adb-execute-adb-command (vec &rest args)
   "Returns nil on success error-output on failure."
-  (when (> (length (tramp-file-name-host vec)) 0)
-    (setq args (append (list "-s" (tramp-file-name-host vec)) args)))
+  (let ((host (tramp-file-name-host vec)))
+    (when (> (length host) 0)
+      (setq args (append (list "-s" (tramp-adb-get-host-for-execution vec)) args))))
   (with-temp-buffer
     (prog1
 	(unless
@@ -1096,6 +1105,7 @@ connection if a previous connection has died for some reason."
   (let* ((buf (tramp-get-connection-buffer vec))
 	 (p (get-buffer-process buf))
 	 (host (tramp-file-name-host vec))
+         (exe-host (tramp-adb-get-host-for-execution vec))
 	 (user (tramp-file-name-user vec))
 	 devices)
 
@@ -1112,7 +1122,7 @@ connection if a previous connection has died for some reason."
 	(setq devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))
 	(if (not devices)
 	    (tramp-error vec 'file-error "No device connected"))
-	(if (and (> (length host) 0) (not (member host devices)))
+	(if (and (> (length host) 0) (not (member exe-host devices)))
 	    (tramp-error vec 'file-error "Device %s not connected" host))
 	(if (and (> (length devices) 1) (zerop (length host)))
 	    (tramp-error
@@ -1122,7 +1132,7 @@ connection if a previous connection has died for some reason."
 	  (let* ((coding-system-for-read 'utf-8-dos) ;is this correct?
 		 (process-connection-type tramp-process-connection-type)
 		 (args (if (> (length host) 0)
-			   (list "-s" host "shell")
+			   (list "-s" exe-host "shell")
 			 (list "shell")))
 		 (p (let ((default-directory
 			    (tramp-compat-temporary-file-directory)))
diff --git a/test/tramp-tests.el b/test/tramp-tests.el
index 864a43d..5ea0291 100644
--- a/test/tramp-tests.el
+++ b/test/tramp-tests.el
@@ -1165,7 +1165,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
 	  (skip-unless (set-file-times tmp-name1 '(0 1)))
 	  ;; Dumb remote shells without perl(1) or stat(1) are not
 	  ;; able to return the date correctly.  They say "don't know".
-	  (unless (equal (nth 5 (file-attributes tmp-name1)) '(0 0))
+	  (unless (or (equal (nth 5 (file-attributes tmp-name1)) '(0 0))
+                      (equal (nth 4 (file-attributes tmp-name1)) '(0 0)))
 	    (should (equal (nth 5 (file-attributes tmp-name1)) '(0 1)))
 	    (write-region "bla" nil tmp-name2)
 	    (should (file-exists-p tmp-name2))
-- 
1.9.1

_______________________________________________
Tramp-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to