* lisp/net/tramp-adb.el (tramp-methods): Use "%d".
(tramp-adb-handle-directory-files-and-attributes): Fix "." and
".." in listing.
(tramp-adb-sh-fix-ls-output): Fix file names with spaces.
(tramp-adb-maybe-open-connection): Compute args from `tramp-login-args'.
* lisp/net/tramp.el (tramp-methods): Adapt docstring.
(tramp-handle-make-process): Check for adb device if indicated.
* test/lisp/net/tramp-tests.el (tramp-test17-insert-directory)
(tramp-test22-file-times): Adapt tests.
(add-to-list 'tramp-methods
`(,tramp-adb-method
(tramp-login-program ,tramp-adb-program)
- (tramp-login-args (("shell")))
+ (tramp-login-args (("-s" "%d") ("shell")))
(tramp-direct-async t)
(tramp-tmpdir "/data/local/tmp")
(tramp-default-port 5555)))
(tramp-compat-file-name-concat localname "."))
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname ".."))))
+ (replace-regexp-in-region
+ (regexp-quote
+ (tramp-compat-file-name-unquote
+ (file-name-as-directory localname)))
+ "" (point-min))
(widen)))
(tramp-adb-sh-fix-ls-output)
(tramp-do-parse-file-attributes-with-ls v))))
Android's \"ls\" command doesn't insert size column for directories:
Emacs dired can't find files."
(save-excursion
+ ;; Fix file names with spaces.
+ ;; FIXME: It would be better if we could call "ls" with proper
+ ;; argument or environment variable.
+ (replace-string-in-region "\\ " " " (point-min))
;; Insert missing size.
(goto-char (point-min))
(while
(with-tramp-progress-reporter vec 3 "Opening adb shell connection"
(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" device "shell")
- (list "shell")))
+ (args (tramp-expand-args
+ vec 'tramp-login-args ?d (or device "")))
(p (let ((default-directory
tramp-compat-temporary-file-directory))
(apply #'start-process (tramp-get-connection-name vec) buf
argument if it is supported.
- \"%z\" is replaced by the `tramp-scp-direct-remote-copying'
argument if it is supported.
+ - \"%d\" is replaced by the device detected by `tramp-adb-get-device'.
The existence of `tramp-login-args', combined with the
absence of `tramp-copy-args', is an indication that the
;; is different between tramp-sh.el, and tramp-adb.el or
;; tramp-sshfs.el.
(let* ((sh-file-name-handler-p (tramp-sh-file-name-handler-p v))
+ (adb-file-name-handler-p (tramp-adb-file-name-p v))
(login-program
(tramp-get-method-parameter v 'tramp-login-program))
;; We don't create the temporary file. In fact, it
(when sh-file-name-handler-p
(tramp-compat-funcall
'tramp-ssh-controlmaster-options v)))
+ (device
+ (when adb-file-name-handler-p
+ (tramp-compat-funcall
+ 'tramp-adb-get-device v)))
login-args p)
;; Replace `login-args' place holders. Split
v 'tramp-login-args
?h (or host "") ?u (or user "") ?p (or port "")
?c (format-spec (or options "") (format-spec-make ?t tmpfile))
- ?l ""))))
+ ?d (or device "") ?l ""))))
p (make-process
:name name :buffer buffer
:command (append `(,login-program) login-args command)
(goto-char (point-min))
(should
(looking-at-p (format "^.+ %s/$" (regexp-quote tmp-name1)))))
- (with-temp-buffer
- (insert-directory
- (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
- (goto-char (point-min))
- (should
- (looking-at-p
- (concat
- ;; There might be a summary line.
- "\\(total.+[[:digit:]]+ ?[kKMGTPEZY]?i?B?\n\\)?"
- ;; We don't know in which order ".", ".." and "foo" appear.
- (format
- "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
- (regexp-opt (directory-files tmp-name1))
- (length (directory-files tmp-name1)))))))
+ (let ((directory-files (directory-files tmp-name1)))
+ (with-temp-buffer
+ (insert-directory
+ (file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
+ (goto-char (point-min))
+ (should
+ (looking-at-p
+ (concat
+ ;; There might be a summary line.
+ "\\(total.+[[:digit:]]+ ?[kKMGTPEZY]?i?B?\n\\)?"
+ ;; We don't know in which order ".", ".." and "foo" appear.
+ (format
+ "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
+ (regexp-opt directory-files)
+ (length directory-files)))))))
;; Check error cases.
(when (and (tramp--test-supports-set-file-modes-p)
(file-attributes tmp-name1))
tramp-time-dont-know)
(should
- (tramp-compat-time-equal-p
- (file-attribute-modification-time (file-attributes tmp-name1))
- (seconds-to-time 1)))
+ (or (tramp-compat-time-equal-p
+ (file-attribute-modification-time
+ (file-attributes tmp-name1))
+ (seconds-to-time 1))
+ ;; Some remote machines cannot resolve seconds.
+ ;; The return the modification time `(0 0).
+ (tramp-compat-time-equal-p
+ (file-attribute-modification-time
+ (file-attributes tmp-name1))
+ (seconds-to-time 0))))
;; Setting the time for not existing files shall fail.
(should-error
(set-file-times tmp-name2)
(with-no-warnings
(set-file-times tmp-name1 (seconds-to-time 1) 'nofollow)
(should
- (tramp-compat-time-equal-p
- (file-attribute-modification-time
- (file-attributes tmp-name1))
- (seconds-to-time 1)))))))
+ (or (tramp-compat-time-equal-p
+ (file-attribute-modification-time
+ (file-attributes tmp-name1))
+ (seconds-to-time 1))
+ ;; Some remote machines cannot resolve seconds.
+ ;; The return the modification time `(0 0).
+ (tramp-compat-time-equal-p
+ (file-attribute-modification-time
+ (file-attributes tmp-name1))
+ (seconds-to-time 0))))))))
;; Cleanup.
(ignore-errors