Subject: bug#68227: 29.1; [tramp] adb stopped working (after upgrade from Emacs 28 to 29?)

From: Michael Albinus <[email-masked]>
Date: Mon, 08 Jan 2024 12:48:53 +0100

Maxim Cournoyer <[email-masked]> writes:

> Hello,

Hi Maxim,

> I have an old Android 6 (!) phone to which I used to be able to copy
> files to/from via TRAMP and its adb support, by visiting the '/adb::'
> file.
>
> It doesn't work anymore: visiting '/adb::' prompts with "File /adb::/ is
> read-only on disk.  Make buffer read-only, too? (y or n)" and if I
> answer "y" an empty buffer is displayed.
>
> I think the main change has been upgrading from Emacs 28 to Emacs 29
> since I last used that.  The software on the phone hasn't budged (you
> can thank HTC for that ^^').
>
> The *tramp/adb * buffer has the following text:
>
>   ls: Unknown option '-1'. Aborting.
>
> which seems like an important clue.  Looking at tramp-adb.el in git
> blame, there does *not* seem to have been a recent change to the "ls"
> command arguments that would explain that new failure.
>
> Using adb directly, I can see:
>
> $ adb devices
> List of devices attached
> HT7281601342    device
>
>
> From an 'adb shell' session:
>
> shell@htc_alpine_dugl:/ $ ls -1
> ls: Unknown option '-1'. Aborting.

I've checked the tramp-adb.el versions integrated into Emacs 28 and
29. The relevant function is identitical:

--8<---------------cut here---------------start------------->8---
(defun tramp-adb-get-ls-command (vec)
  "Determine `ls' command and its arguments."
  (with-tramp-connection-property vec "ls"
    (tramp-message vec 5 "Finding a suitable `ls' command")
    (cond
     ;; Support Android derived systems where "ls" command is provided
     ;; by GNU Coreutils.  Force "ls" to print one column and set
     ;; time-style to imitate other "ls" flavors.
     ((tramp-adb-send-command-and-check
       vec (concat "ls --time-style=long-iso "
                   (tramp-get-remote-null-device vec)))
      "ls -1 --time-style=long-iso")
     ;; Can't disable coloring explicitly for toybox ls command.  We
     ;; also must force "ls" to print just one column.
     ((tramp-adb-send-command-and-check vec "toybox") "ls -1")
     ;; On CyanogenMod based system BusyBox is used and "ls" output
     ;; coloring is enabled by default.  So we try to disable it when
     ;; possible.
     ((tramp-adb-send-command-and-check
       vec (concat "ls --color=never -al " (tramp-get-remote-null-device vec)))
      "ls --color=never")
     (t "ls"))))
--8<---------------cut here---------------end--------------->8---

So there is no reason to behave differently. However, the result of this
function is cached. There might be something unstale. Could you, pls,
try to test w/o cached properties? That is, call

--8<---------------cut here---------------start------------->8---
# emacs -Q /adb::
--8<---------------cut here---------------end--------------->8---

Best regards, Michael.