Open dreirund opened 8 months ago
While I'd love to see this feature built-in, I just found a workaround: set an environment variable ANDROID_SERIAL="02b5c5a809117c73" (taking the example you gave) before starting adbfs, e.g.
ANDROID_SERIAL="02b5c5a809117c73" ./adbfs /mnt/android
Tip - I have written this snippet just for that:
#!/bin/bash
# Get the serial number of the first device
ANDROID_SERIAL=$(adb devices | awk 'NR==2 {print $1}')
# Check if a device was found
if [ -z "$ANDROID_SERIAL" ]; then
echo "No device found."
exit 1
fi
# Set the ANDROID_SERIAL environment variable
export ANDROID_SERIAL
# Unmount the existing mountpoint
sudo fusermount -u /media/android_via_adb_adbfs_mountpoint
# Mount the Android device file system
sudo -E /usr/bin/adbfs /media/android_via_adb_adbfs_mountpoint -o allow_other
# Open the mounted directory in Nautilus, nemo etc.
nemo /media/android_via_adb_adbfs_mountpoint
Tip - I have written this snippet just for that:
You seem to have messed up the markdown formatting, @Manamama.
Try to change the
`
to
```bash
(the trailing bash
is optional, and only at the opening triple backticks, not at the end.)
Regards!
I just found a workaround: set an environment variable
ANDROID_SERIAL="02b5c5a809117c73"
OK, I made a wrapper script:
adbfs-devspecific.sh
Note: I previously had a bogous script, see this follow-up comment by @Manamama. For reference, I keep the bogous script here:
adbfs-devspecific.sh_-_BOGOUS
.
@dreirund -
adbfs-devspecific.sh --help
Usage:
* /home/zezen/Downloads/adbfs-devspecific.sh --help
* /home/zezen/Downloads/adbfs-devspecific.sh -D [Android Device ID] <adbfs-options>
Where '[Android Device ID]' is a serial number as shown by 'adb devices'.
Runs 'adbfs' only for the specified android device.
but:
`adbfs-devspecific.sh -D ZHE{xyz}`
->
> Error: Second argument needs to be an Android device ID.
Ms Bing gracefully comments upon perusal thereof:
> The error is in the regular expression used to validate the Android device ID. The script checks if the second argument matches the regular expression [0-9a-fA-F]*, which is a sequence of hexadecimal digits.
> However, Android device IDs are not limited to hexadecimal characters. They can contain any alphanumeric characters (both uppercase and lowercase) as well as special character...
->
case "$2" in [0-9a-zA-Z]) shift shift ;; ) errmsg "$0: Error: Second argument needs to be an Android device ID." errmsg "" errmsg "Run '$0 --help' for usage info." errmsg "" errmsg "Aborting." exit 3 ;; esac
But then, again, if e.g.:
adb devices
List of devices attached
ZHE6{xyz} device
192.168.221.156:5555 device
192.168.44.1:5555 device
->
and here I (and Ms Bing) give up.
However, Android device IDs are not limited to hexadecimal characters.
Thanks for informing me, I updated my script (now to accept any non-empty string).
Also, I actually did forget the most important stuff, to actually set ANDROID_SERIAL
after all the parsing and testing.
Updated script in my original comment.
Confirmed to work @dreirund , also on my finicky (rooted, with e.g. nano in the /bin, Magisked, triply connected, also via BT, etc) Droid. My suggestion, as per the above - add it to the base options. Bows
My suggestion, as per the above - add it to the base options.
I do not understand what you mean by this.
Re
My suggestion, as per the above - add it to the base options.
I should have looked up the names.
Self-fix :
My suggestion, for @spion, as per the above comment by @dreirund : do (@spion) add the wrapper's functionality, to the base switches, e.g.
-o android_device
(as per @dreirund's original idea, once again).
As what the the old/ orphaned "
zach-klippenstein/adbfs
" provided, I hereby feature-request an option to specify which android device to mount, e.g../adbfs -o android_device 02b5c5a809117c73 /mnt/android
This is useful e.g. if
Regards!