From 1a82330cc569deda2b37b228d7a16ec6fb65f67a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20H=C3=B6tzel?= Date: Mon, 31 Dec 2012 16:29:23 +0100 Subject: [PATCH] * net/tramp-adb.el (tramp-adb-maybe-open-connection): Handle errors (No device connected, invalid device name). (Bug #13299) --- lisp/ChangeLog | 5 +++++ lisp/net/tramp-adb.el | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 88200a27133..7e9e9d7738e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-12-31 Jürgen Hötzel + + * net/tramp-adb.el (tramp-adb-maybe-open-connection): Handle errors + (No device connected, invalid device name). (Bug #13299) + 2012-12-31 Martin Rudalics * window.el (window-resizable--p): Rename to window-resizable-p. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index f31bd6b3d2d..b418d1982d9 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -998,11 +998,24 @@ COMMAND is nil, just sends `echo $?'. Returns the exit status found." Does not do anything if a connection is already open, but re-opens the connection if a previous connection has died for some reason." (let* ((buf (tramp-get-connection-buffer vec)) - (p (get-buffer-process buf))) + (p (get-buffer-process buf)) + (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) (unless (and p (processp p) (memq (process-status p) '(run open))) (save-match-data (when (and p (processp p)) (delete-process p)) + (if (not devices) + (tramp-error vec 'file-error "No device connected")) + (if (and (tramp-file-name-host vec) + (not (member (tramp-file-name-host vec) devices))) + (tramp-error + vec 'file-error + "Device %s not connected" (tramp-file-name-host vec))) + (if (and (not (eq (length devices) 1)) + (not (tramp-file-name-host vec))) + (tramp-error + vec 'file-error + "Multiple Devices connected: No Host/Device specified")) (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) -- 2.39.2