Function: tramp-androidsu-generate-wrapper

tramp-androidsu-generate-wrapper is a byte-compiled function defined in tramp-androidsu.el.gz.

Signature

(tramp-androidsu-generate-wrapper FUNCTION)

Documentation

Return connection wrapper function for FUNCTION.

Return a function which temporarily substitutes local replacements for the adb method's connection management functions around a call to FUNCTION.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-androidsu.el.gz
(defun tramp-androidsu-generate-wrapper (function)
  "Return connection wrapper function for FUNCTION.
Return a function which temporarily substitutes local replacements for
the `adb' method's connection management functions around a call to
FUNCTION."
  (lambda (&rest args)
    (let ((tramp-adb-wait-for-output
           (symbol-function #'tramp-adb-wait-for-output))
          (tramp-adb-maybe-open-connection
           (symbol-function #'tramp-adb-maybe-open-connection)))
      (unwind-protect
          (progn
            ;; `tramp-adb-wait-for-output' addresses problems introduced
            ;; by the adb utility itself, not Android utilities, so
            ;; replace it with the regular Tramp function.
            (fset 'tramp-adb-wait-for-output #'tramp-wait-for-output)
            ;; Likewise, except some special treatment is necessary on
            ;; account of flaws in Android's su implementation.
            (fset 'tramp-adb-maybe-open-connection
                  #'tramp-androidsu-maybe-open-connection)
            (apply function args))
        ;; Restore the original definitions of the functions overridden
        ;; above.
        (fset 'tramp-adb-wait-for-output tramp-adb-wait-for-output)
        (fset 'tramp-adb-maybe-open-connection
              tramp-adb-maybe-open-connection)))))