]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp-adb.el
Update copyright dates to 2013.
[gnu-emacs] / lisp / net / tramp-adb.el
index f31bd6b3d2d110a8e7ae638e16f8ad814a11eec3..b5f99ffc93c3a16572f126cae1ca9d1d26983584 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp
 
-;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
 ;; Author: Juergen Hoetzel <juergen@archlinux.org>
 ;; Keywords: comm, processes
@@ -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)