X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/06b583dec7cbde714c8fb991a1e123f612b66e3a..970ad972b936db89b62798a0abb2401c61f404df:/lisp/net/tramp-adb.el diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 910356fbb6..14fb8575ff 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -155,12 +155,18 @@ pass to the OPERATION." "Return a list of (nil host) tuples allowed to access." (with-timeout (10) (with-temp-buffer - (when (zerop (call-process tramp-adb-program nil t nil "devices")) - (let (result) - (goto-char (point-min)) - (while (search-forward-regexp "^\\(\\S-+\\)[[:space:]]+device$" nil t) - (add-to-list 'result (list nil (match-string 1)))) - result))))) + ;; `call-process' does not react on timer under MS Windows. + ;; That's why we use `start-process'. + (let ((p (start-process + tramp-adb-program (current-buffer) tramp-adb-program "devices")) + result) + (tramp-compat-set-process-query-on-exit-flag p nil) + (while (eq 'run (process-status p)) + (sleep-for 0.1)) + (goto-char (point-min)) + (while (search-forward-regexp "^\\(\\S-+\\)[[:space:]]+device$" nil t) + (add-to-list 'result (list nil (match-string 1)))) + result)))) (defun tramp-adb-handle-expand-file-name (name &optional dir) "Like `expand-file-name' for Tramp files." @@ -369,16 +375,6 @@ pass to the OPERATION." "ls --color=never" "ls"))) -(defun tramp-adb-get-toolbox (vec) - "Get shell toolbox implementation: `toolbox' for original distributions -or `busybox' for CyanogenMod based distributions" - (with-tramp-connection-property vec "toolbox" - (tramp-message vec 5 "Checking shell toolbox implementation") - (cond - ((zerop (tramp-adb-command-exit-status vec "busybox")) 'busybox) - ((zerop (tramp-adb-command-exit-status vec "toolbox")) 'toolbox) - (t 'unknown)))) - (defun tramp-adb--gnu-switches-to-ash (switches) "Almquist shell can't handle multiple arguments. @@ -850,7 +846,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (when p (if (yes-or-no-p "A command is running. Kill it? ") (ignore-errors (kill-process p)) - (error "Shell command in progress"))) + (tramp-compat-user-error "Shell command in progress"))) (if current-buffer-p (progn @@ -976,11 +972,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (setq args (append (list "-s" (tramp-file-name-host vec)) args))) (with-temp-buffer (prog1 - (unless (zerop (apply 'call-process tramp-adb-program nil t nil args)) + (unless + (zerop (apply 'tramp-call-process tramp-adb-program nil t nil args)) (buffer-string)) - (tramp-message - vec 6 "%s %s\n%s" - tramp-adb-program (mapconcat 'identity args " ") (buffer-string))))) + (tramp-message vec 6 "%s" (buffer-string))))) (defun tramp-adb-find-test-command (vec) "Checks, whether the ash has a builtin \"test\" command. @@ -1074,6 +1069,13 @@ connection if a previous connection has died for some reason." (host (tramp-file-name-host vec)) (user (tramp-file-name-user vec)) (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) + + ;; Maybe we know already that "su" is not supported. We cannot + ;; use a connection property, because we have not checked yet + ;; whether it is still the same device. + (when (and user (not (tramp-get-file-property vec "" "su-command-p" t))) + (tramp-error vec 'file-error "Cannot switch to user `%s'" user)) + (unless (and p (processp p) (memq (process-status p) '(run open))) (save-match-data @@ -1133,7 +1135,9 @@ connection if a previous connection has died for some reason." (tramp-adb-send-command vec (format "su %s" user)) (unless (zerop (tramp-adb-command-exit-status vec nil)) (delete-process p) - (tramp-error vec 'file-error "Cannot switch to user %s" user))) + (tramp-set-file-property vec "" "su-command-p" nil) + (tramp-error + vec 'file-error "Cannot switch to user `%s'" user))) ;; Set "remote-path" connection property. This is needed ;; for eshell.