Forum › Forums › antiX-development › Development › Trying to “fix” android-device-usb-connect.sh
- This topic has 15 replies, 4 voices, and was last updated Dec 14-8:06 pm by rokytnji.
-
AuthorPosts
-
December 12, 2022 at 5:00 pm #95453Member
PPC
I recently took a look at the script that mounts android devices in antiX. It works fine with both my devices (android 8 and android 10 or 11), so I can’t find out what’s wrong with it, because some users report it fails to mount some android devices.
Unless you can send me one of the devices that fails to mount 🙂 the only way I can try to fix the script is if you tell me exactly what happens when you try to mount your android devices. Please try to run the script via the terminal and paste it’s output here – that probably could help me debug the script: antiX menu > Terminal and run the command:
android-device-usb-connect.sh
If the script fails to work for you, paste it’s output here, please
P.
December 12, 2022 at 7:46 pm #95468Forum Admin
rokytnji
::Samsung S10E. Android 12. Dell 64 bit antiX 21/22 full iso install.
After picking trust on phone. No problemo. I’ll try later on my chromebook antiX 22 full iso 64 bit install. I’ll just edit this post if it works. If not. It will be a new post. Being lazy. I launched it from menu>applications>antiX instead.
Works on chromebook install also.
- This reply was modified 4 months, 3 weeks ago by rokytnji.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsDecember 12, 2022 at 8:15 pm #95470Forum Admin
rokytnji
::Ok. Moved some files in roxfm.
No problem.When I went to unmount option in right click on rox file manager. Got the error screen then.
or directory Unmount failed Done There was one error.Not a biggy right now. ZZZfm has no unmount option. antiX usb unmounter does not say anything is mounted though a android folder with green mounted icon sits in /home/username. Just supplying info. I am not a big phone type of guy. Ever since my wife turned off my data plan. My phone aint my campfire router anymore.
Happy trails.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsDecember 12, 2022 at 8:49 pm #95471MemberPPC
::ZZZfm has no unmount option. antiX usb unmounter does not say anything is mounted
If you run the script again, and it detects that an android device is mounted, it should ask if you want to open the device on the File Manager or unmount it…
You can’t use the usb unomounter to in android devices, they are mounted in a different way than ordinary usb devices, to I built that safeguard…
December 12, 2022 at 11:07 pm #95484Forum Admin
rokytnji
::Thanks. I just showed how much I use this. 😀
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsDecember 13, 2022 at 6:12 am #95514ModeratorBobC
::Do you know what android version has problems?
I do have an old phone of my wifes from before the most recent tower upgrades. Its about 3 or 4 years old.
What is the sequence of tests you want to run?
December 13, 2022 at 9:56 am #95523MemberPPC
::Hi BobC.
A user reported to me this: “certain Redmi Note 11, Redmi Note 5 Honor 9X Pro will not mount with the antiX provided script”
My most recent android device is some 3 years old now, the oldest device is my android 4.4.1 tablet. I also have access to an android 9(?) phone that’s about 3 years old(?). They all mount fine using the script.
Moddit’s tiny CLI script is reported to work on all those devices. I repeatedly tried that script on my computer, with my phones – most of the time it seems to work fine. I began trying to put my GUI on top of that script only to realize that the script no longer worked- for some reason, I had to restart my computer for it to work – it may have been some USB related problem because sometimes, when the phone refused to mount my USB mouse stopped working, and only resumed when I unplugged my phone…
I’ll try again, that script with another computer- I have my work desktop back, I no longer have to use my old crappy netbook as a “desktop” (my current desktop is a “powerhouse” by comparison- it’s a quad core with 2 Gb of RAM – a busted sound card and a busted memory slot, yet, fully usable for office work 🙂 antiX is happy with 2Gb of RAM and if I really wanted sound to further distract me at my office, I would just buy a 10 euros USB sound card and plug it in).
Basically the simpler CLI script that works differs from the foundation of my script (the detect and mount the device part, that is just a series of simple commands) by the way it checks if the user has to allow access to the android device on the device it self (i.e tapping the “Allow” option or the “Transfer files” option from the notification area). My best bet is that the problem lies on that part of the script, that fails to detect that the user has provided access on the android device. It probably is something dead simple, that’s staring me right in the eye…
One basic “problem” that I noticed in my GUI is that the window that states that the user has to authorize access in the android device should have the –on-top flag, because some android devices, when they are mounted, they instantly open the file manager, showing a pseudo usb drive that displays the windows drivers for that device, but is not the “normal” device’s contents (i.e – the internal drive or the sd card). You have to ignore what is displayed in the File Manager and return to the script’s yad window and click the button to mount the device… Could it simply be an UX problem: users not realizing that they have to do that?
P.
December 13, 2022 at 1:49 pm #95528ModeratorBobC
::You need to find out what android version the failing device is running.
One uses android 9 pie the other android 8 creo
I don’t have either of those versions on any of my devices.
You should get the person with problems to test if possible.
December 13, 2022 at 2:52 pm #95532MemberPPC
::I negleted to state here that I’ve tried the current version of the script with devices that are this versions of android: 4.4.1; 8; 9; 10 and 11- and it worked on all of them.
I cuted and pasted together a newer and test version only, of the script (sorry Sybok, it’s a mess, no funtions, I just wanted to test the changes)
Anyone that reported problems with the current version of the script, please do test this (localization is not working for this version, there were too many changes)
Code: EDIT: PLEASE TRY THE MORE RECENT CODE, AVAILABLE BELOW!!!
#!/bin/bash # Smaller script to mount android devices- By PPC, for antiX Linux - GPL license, please keep this line, but you are free to use or adapt this script dir="$HOME/android_device" mkdir -p "$dir" yad_title=$"Android Device USB Connect" yad_window_icon="phone" yad_image="/usr/share/icons/papirus-antix/48x48/devices/smartphone.png" #1- Check if a android device seems to be mounted. If so, offer to unmount it and exit OR to access device if find "$dir" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then echo $"An android device seems to be mounted" yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"An android device seems to be mounted.\n \nChoose 'Unmount' to unplug it safely OR \n Choose 'Access device' to view the device's contents again. " --button=$"Access device":1 --button=$"Unmount":2 foo=$? [[ $foo -eq 1 ]] && echo $"User has chosen to access the android device" && desktop-defaults-run -fm "$dir" && exit 1 [[ $foo -eq 2 ]] && echo $"User has chosen to unmount the android device" && fusermount -u "$dir" && rm -r "$dir" ###&& exit #### NEW confirmation dialog, that warns if it's safe to unplug the device if [ "$(ls -A "$dir")" ]; then echo $"Android device WAS NOT umounted for some reason, do not unplug!" yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"Android device WAS NOT umounted for some reason, do not unplug!" --button=$"OK" && exit else echo $"Android device is umounted; it is safe to unplug!" yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"Android device is umounted; it is safe to unplug!" --button=$"OK" && exit fi fi # 2- Check if an android device is connected to the computer, if not, warn user and exit while : do device_check=$(jmtpfs 2>&1) if [[ $device_check == *"No mtp"* ]]; then echo $"No device connected" else echo $"Device is connected" && sleep 1 && break fi yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"No (MTP enabled) Android device found!\n \n Connect a single device using its USB cable and \n make sure to select 'MTP' or 'File share' option and retry. \n" --button=$"EXIT":1 --button=$"Retry":2 foo=$? [[ $foo -eq 1 ]] && echo $"User pressed Exit" && exit 1 [[ $foo -eq 2 ]] && echo $"User pressed Retry" done # 3- Main part of the script: try to mount android device and show it's contents in the default File Manager yad --center --text="Make sure your android device is connected to this computer via an USB cable and\n Select 'Allow'/'Transfer Files' or any similar option on your android device's screen or notification area" --button="OK" && fusermount -u "$dir" jmtpfs "$dir" if find "$dir" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then echo $"The device seems to be correctly mounted." && fusermount -u "$dir" && jmtpfs "$dir" && desktop-defaults-run -fm "$dir" && exit else echo "Failed to mount the android device" fiP.
- This reply was modified 4 months, 3 weeks ago by PPC.
- This reply was modified 4 months, 3 weeks ago by PPC.
December 13, 2022 at 3:53 pm #95541Memberctcx
::Just trying to put my tiny sand grain here.
I have also used the script -via terminal- with either old devices -circa 6 years old- and recent ones. They have been a couple ones already; I’m sorry I can no longer recall the exact models…
So far no problems with the script in itself; if anything there were issues but with the Android versions, some needed settings or the like.Which would make me think about the particular Xiaomi Redmi devices: they use their own modified Android version called MIUI.
At least personally, I’d suspect the system in particular
Unless you say that other users have also reported problems with other stock Android versions…December 13, 2022 at 5:30 pm #95549Forum Admin
rokytnji
::test on antiX 22 chromebook with same phone as yesterday with the new script.
harry@antix1:~ $ ./android_mount.sh mkdir: cannot stat ‘/home/harry/android_device’: Input/output error Device is connected Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP). Android device detected, assigning default bug flags Failed to mount the android device harry@antix1:~ $ ls ls: cannot access 'android_device': Input/output error android_device Documents mpv.sh UCM android_mount.sh Downloads Music Videos Desktop Live-usb-storage Pictures WallpaperJust figured I’d mention the permission denied when it came to opening android_device folder and green mount dot
is gone. Your new script I called it. android_mount.sh. Just temporary testing.Edit: Now I have android_device yellow icon with a explanation point in the middle.
Rox file manager as root cannot delete it.
2nd edit: which broke the working android mounting device in menu. Error on android_device folder.3rd edit: reading things right now. I see I need not ran that script since I had no problems.
Duh.4th edit: Fixed. I guess rox delete icon as root worked. Ran menu again instead of file .sh made. Everything back to normal.
Gonna delete the test .sh I made.- This reply was modified 4 months, 3 weeks ago by rokytnji.
- This reply was modified 4 months, 3 weeks ago by rokytnji.
- This reply was modified 4 months, 3 weeks ago by rokytnji.
Sometimes I drive a crooked road to get my mind straight.
Not all who Wander are Lost.
I'm not outa place. I'm from outer space.Linux Registered User # 475019
How to Search for AntiX solutions to your problemsDecember 13, 2022 at 7:06 pm #95559MemberPPC
::Hi, Roky – if any of my android scripts fails to unmount the mount point, please unplug any device and run this command:
fusermount -u ~/android_device
if still the mount point appears in the File Manger then:
sudo umount ~/android_device
should solve the problem.
I changed the script to always do a fusermount -u ~/android_device if no android device is detected. It should stop anything like that happening again (I did not experience that problem)…
code:
#!/bin/bash # Smaller script to mount android devices- By PPC, for antiX Linux - GPL license, please keep this line, but you are free to use or adapt this script dir="$HOME/android_device" mkdir -p "$dir" yad_title=$"Android Device USB Connect" yad_window_icon="phone" yad_image="/usr/share/icons/papirus-antix/48x48/devices/smartphone.png" #1- Check if a android device seems to be mounted. If so, offer to unmount it and exit OR to access device if find "$dir" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then echo $"An android device seems to be mounted" yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"An android device seems to be mounted.\n \nChoose 'Unmount' to unplug it safely OR \n Choose 'Access device' to view the device's contents again. " --button=$"Access device":1 --button=$"Unmount":2 foo=$? [[ $foo -eq 1 ]] && echo $"User has chosen to access the android device" && desktop-defaults-run -fm "$dir" && exit 1 [[ $foo -eq 2 ]] && echo $"User has chosen to unmount the android device" && fusermount -u "$dir" && rm -r "$dir" ###&& exit #### NEW confirmation dialog, that warns if it's safe to unplug the device if [ "$(ls -A "$dir")" ]; then echo $"Android device WAS NOT umounted for some reason, do not unplug!" yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"Android device WAS NOT umounted for some reason, do not unplug!" --button=$"OK" && exit else echo $"Android device is umounted; it is safe to unplug!" yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"Android device is umounted; it is safe to unplug!" --button=$"OK" && exit fi fi # 2- Check if an android device is connected to the computer, if not, warn user and exit while : do device_check=$(jmtpfs 2>&1) if [[ $device_check == *"No mtp"* ]]; then echo $"No device connected" else echo $"Device is connected" && sleep 1 && break fi yad --fixed --window-icon=$yad_window_icon --image=$yad_image --title "$yad_title" --center --text=$"No (MTP enabled) Android device found!\n \n Connect a single device using its USB cable and \n make sure to select 'MTP' or 'File share' option and retry. \n" --button=$"EXIT":1 --button=$"Retry":2 foo=$? [[ $foo -eq 1 ]] && echo $"User pressed Exit" && fusermount -u $dir && exit 1 [[ $foo -eq 2 ]] && echo $"User pressed Retry" done # 3- Main part of the script: try to mount android device and show it's contents in the default File Manager yad --center --text="Make sure your android device is connected to this computer via an USB cable and\n Select 'Allow'/'Transfer Files' or any similar option on your android device's screen or notification area" --button="OK" && fusermount -u "$dir" jmtpfs "$dir" if find "$dir" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then echo $"The device seems to be correctly mounted." && fusermount -u "$dir" && jmtpfs "$dir" && desktop-defaults-run -fm "$dir" && exit else echo "Failed to mount the android device" fusermount -u $dir fiEdit: corrected a problem with “&&”, thanks, Bobc!
- This reply was modified 4 months, 3 weeks ago by PPC.
December 14, 2022 at 2:49 pm #95626ModeratorBobC
::Line 36 has extra &&
[[ $foo -eq 1 ]] && echo $"User pressed Exit" && && fusermount -u $dir && exit 1After fixing that, it worked on my current phone.
I need to get the password for the old one still, to try it.
December 14, 2022 at 3:04 pm #95631MemberPPC
::Thanks, Bob, I just fixed the code on my previous post- I must have copied and pasted from an older test script… I hope I didn’t miss any more “bugs”. Lets wait and see what users with android devices that refused to be mounted say about the new script. If it works, I’ll have to touch it a bit and prepare it for localization… Roky had problems with the first version of the script I proposed here, so I added that “fusermount -u” safeguard.
P.
December 14, 2022 at 5:55 pm #95655ModeratorBobC
::On android 4.4.4 on Huwei g820-a2 I couldn’t get the phone to ask permission.
The phone seems to be working, but not sure the SIM card is valid anymore, so its possible that is the cause.
My current Samsung Galaxy J727U running android 8.1.0 worked fine.
- This reply was modified 4 months, 3 weeks ago by BobC.
-
AuthorPosts
- You must be logged in to reply to this topic.