Android connection to Argent

From Argent Wiki

Connecting an Android phone to Argent

The short version: plug the phone in with a USB cable, unlock it, choose File transfer on the phone, and open it from the Devices panel in Dolphin.

The long version is below: what works out of the box, what to do when the phone doesn't show up, how to copy a lot of files fast with adb, and how to use KDE Connect over Wi-Fi.

What Argent ships

Argent KDE comes with everything needed to browse a phone over USB:

  • kde-apps/kio-extras built with the mtp flag, which gives Dolphin the mtp:/ protocol
  • media-libs/libmtp, with the udev rules that give your user access to the phone
  • gnome-base/gvfs with MTP support, for GTK programs

Two things are not installed by default and are covered below:

  • dev-util/android-tools for adb (fast copying of many files, shell on the phone)
  • kde-misc/kdeconnect for KDE Connect (phone and desktop over Wi-Fi)

USB cable: browsing the phone in Dolphin

Modern Android phones don't show up as a USB disk. They use MTP (Media Transfer Protocol), and Dolphin speaks it directly.

  1. Plug the phone in.
  2. Unlock the phone. A locked phone charges but refuses file access.
  3. On the phone, pull down the notification shade, tap the USB notification (it usually says Charging this device via USB) and choose File transfer (some phones call it Transfer files or MTP). Phones like OnePlus and Samsung may also show an Allow access to phone data? popup, accept it.
  4. On Argent, Plasma shows the phone in the Device Notifier in the system tray, and Dolphin lists it in the Devices section of the left panel. Click it.

You can also type mtp:/ in the Dolphin location bar to see all connected phones.

Inside you'll find Internal shared storage (and SD card if the phone has one), with the usual folders: DCIM for the camera, Pictures, Download, Documents, Music and so on. Copy files in both directions like with any other folder.

What to expect from MTP

MTP is fine for photos, a few videos or a handful of documents. It is slow for many small files: every file costs several USB round trips, so a folder with thousands of files moves at 1 or 2 MB/s no matter how fast the cable is, while a single big file moves at 25 to 35 MB/s on USB 2.0.

MTP also cannot resume. If the phone locks, switches USB mode or drops the connection in the middle of a copy, the file in flight is incomplete and you must copy it again.

If you need to move thousands of files (a backup, a music library), pack them into one archive first or use adb (below).

Most phones are connected at USB 2.0 speed even if the phone supports USB 3. The cable that comes in the box is usually USB 2.0. For USB 3 speed you need a USB 3 cable in a USB 3 port.

When the phone doesn't show up

Go through these in order.

1. The phone is in the wrong mode or locked. Unlock it and set the USB mode to File transfer again. Phones fall back to Charging only every time you plug them in. Check with:

journalctl -k -b | grep -i usb | tail

You should see the phone being found with a Product: line. If nothing appears when you plug it in, try another cable or port, many cheap cables are charge-only.

2. In case KDE MTP demon gets stuck with 2 android phones in the same time. This is the most common problem. If the phone was locked when you plugged it in, or a copy was interrupted, the daemon that Dolphin uses (kmtpd, running inside kiod6) can keep the phone claimed in a dead session. Dolphin then says The file or folder udi=... does not exist or just shows an empty window, and the system journal has lines like:

org.kde.kmtpd5: LIBMTP PANIC: failed to open session on second attempt
org.kde.kmtpd5: Error 2: PTP Layer error 02fe: LIBMTP_Get_File_To_File_Descriptor(): Could not get file from device.

The fix is to restart the daemon. Run as your user (not root):

pkill -x kiod6

Then open the phone in Dolphin again. The daemon starts again by itself on the next access. If that alone doesn't help, unplug and replug the phone as well.

3. Check what the system sees. Install media-libs/libmtp tools if missing and run, as your user:

mtp-detect

It must list the phone and print its storage. If it says device is busy, likely in use by GVFS or KDE MTP device handling, something is holding the phone: do step 2.

4. Something else is running. If you have another MTP program open (another file manager, a photo importer, a virtual machine with USB passthrough), close it. Only one program can talk MTP to the phone at a time.

Copying many files fast: adb

adb (Android Debug Bridge) copies whole directories with much less overhead than MTP, usually 10 to 30 MB/s even for small files, and it resumes nothing either but it rarely fails. It also gives you a shell on the phone.

Installing

epkg i dev-util/android-tools

This also pulls in the udev rules so adb works as your normal user.

Enabling USB debugging on the phone

This is not USB tethering. It's a developer setting:

  1. Settings > About phone (on OnePlus: About device > Version) and tap Build number 7 times. The phone tells you Developer options are enabled.
  2. Settings > System > Developer options (on OnePlus: Additional settings > Developer options) and switch on USB debugging.
  3. Unplug and replug the cable. The phone asks Allow USB debugging? with the computer's key fingerprint. Tick Always allow from this computer and accept.

The phone now shows both an MTP and an ADB interface, so Dolphin keeps working too.

Using it

Check that the phone is seen and authorized:

$ adb devices
List of devices attached
3B166G00VPR00000       device

If it says unauthorized, the popup on the phone is still waiting for you. If the list is empty, USB debugging is not on, see above.

Copy a directory from Argent to the phone (no trailing slash on the source, so the directory itself is created on the phone):

adb push ~/Pictures/Holiday /sdcard/Pictures/

Copy from the phone to Argent:

adb pull /sdcard/DCIM/Camera ~/Pictures/

Count files on the phone to check a copy:

adb shell find /sdcard/Pictures/Holiday -type f | wc -l

/sdcard is the same Internal shared storage you see in Dolphin.

When you're done, turn USB debugging off again in Developer options. Leaving it on is a security risk if the phone is plugged into a computer you don't trust.

KDE Connect: phone and desktop over Wi-Fi

KDE Connect links the phone and Argent over the local network, no cable needed. It can send files in both directions, share the clipboard, show phone notifications on the desktop, use the phone as a remote control or touchpad, ring a lost phone, and browse the phone's storage from Dolphin.

Installing

On Argent:

epkg i kde-misc/kdeconnect

Log out and back in once so the KDE Connect service and the system tray icon start.

On the phone, install KDE Connect from F-Droid or Google Play.

Pairing

  1. Connect the phone and Argent to the same Wi-Fi network. Guest networks and some public Wi-Fi block devices from seeing each other, KDE Connect won't work there.
  2. Open the KDE Connect app on the phone. Your Argent computer appears under Available devices. Tap it, then Request pairing.
  3. On Argent a notification appears, click Accept. You can also pair from the other side: System Settings > KDE Connect > pick the phone > Request pair.

If the devices don't see each other, open Add devices by IP in the phone app and type the Argent IP address (ip -4 addr on Argent). Argent has no firewall enabled by default, so no ports need opening. If you turned on ufw or nftables yourself, allow TCP and UDP 1714 to 1765.

Sending files

  • From Argent to the phone: right click a file in Dolphin > Share > the phone's name. Or drag files onto the phone entry in the Dolphin Devices panel. From a terminal: kdeconnect-cli --share file.pdf -n "My Phone"
  • From the phone to Argent: in any app use Share > KDE Connect > your computer. Files land in ~/Downloads.
  • Browsing the phone: in Dolphin, the paired phone is listed under Devices and you can open its storage like a folder. On the phone, the KDE Connect app needs Filesystem expose enabled and storage permission granted. On Argent this uses net-fs/sshfs, install it if browsing does nothing.

KDE Connect sends files over Wi-Fi, so it's slower than a cable for big transfers. For a few photos or a PDF it's the most convenient way.

USB tethering: internet from the phone

Unrelated to files, but people mix them up. If you want Argent to use the phone's mobile data: plug the phone in, then on the phone go to Settings > Connections (or Network) > Hotspot and tethering > switch on USB tethering. Argent gets a new wired network connection automatically through NetworkManager, nothing to configure.

Which one to use

What you want Use
Look around the phone, copy some photos or documents Dolphin over USB (MTP)
Copy thousands of files, a backup, a music library adb push / adb pull
Send a file to the phone without a cable, share the clipboard, see notifications KDE Connect
Get internet from the phone USB tethering