[Q] execute batch file when MTP device plugged in - General Questions and Answers

Since MTP does not allocate a drive letter to the device, you cannot use cd /D x:/ to change to your phone's storage. I want to build a simple script that does something when I plug in my phone (automatically).
Basically as an end result I want to be able to write a script that executes when my device is plugged in..
Device: Galaxy S4 mini

Related

Tetherbot not working for Linux :(

Can someone help?
I got it working on XP but I also have Linux (Ubuntu) installed on this machine.
I can't seem to get it to work though.
Install the app on your android phone (DONE)
Turn USB debugging on on your phone (DONE)
On your G1 go to the home screen, press MENU > Settings > Applications > Development, then enable USB debugging. (DONE)
Follow the instructions here to install the Android driver (STUCK)
I tried creating the file and it saved ok but when I closed it, I got this error.
Code:
[email protected]:~$ sudo gedit /etc/udev/rules.d/50-android.rules
[sudo] password for lukehluke:
** (gedit:5985): WARNING **: Could not write gedit state file: Failed to create file '/root/.gnome2/gedit-2.6C18MU': No such file or directory
I/O error : No such file or directory
I/O error : No such file or directory
I have Intrepid and not Gusty/Hardy or Dapper.
Download and install the ADB utility from here (DONE)
Plug your phone into your computer (DONE)
Also when I try excuting the ADB file, I get the following error.
Code:
[email protected]:~$ /home/lukehluke/Desktop/adb/adb.exe forward tcp:1080 tcp:1080
run-detectors: unable to find an interpreter for
/home/lukehluke/Desktop/adb/adb.exe
Not sure about the first error. You might want to retry editing the rules file using nano or vim or emacs.
As for the second, you seem to have installed the windows version of the sdk or your path is point to the windows binaries.
Sounds like you don't have a /root directory? I've never seen that error before. If you want to use gedit, create the file in your home directory, then sudo mv it to /etc/udev/rules.d
As for the second, you need to install the android sdk for linux. The code is available from here: http://code.google.com/android/download.html
There may be a deb for ubuntu somewhere if you google. I just compiled it. The SDK contains the adb utility.
Lukehluke said:
Code:
[email protected]:~$ /home/lukehluke/Desktop/adb/adb.exe forward tcp:1080 tcp:1080
run-detectors: unable to find an interpreter for
/home/lukehluke/Desktop/adb/adb.exe
Click to expand...
Click to collapse
WTF? Can adb.exe be executed on Linux??
You'll enjoy a lot more success if you stop trying to run executables compiled for Windows in Linux
Do you need USB 2.0 for the tethering to work, or even just adb & mounting the G1 as a storage device? On my one laptop (w/ USB 2.0) I can adb into it fine, I have Ubuntu 8.10 and I never had to install any drivers (not manually at least), I never tried the tethering because I just do it through wireless using iptables -- if I ever need it.
The problem is with an older Toshiba laptop that has no NIC or wireless, I could get a dongle but I wanted to try changing the system wide proxy to go to the G1 once its plugged in -- make this into like my car PC or something. I only have a basic command line install of Ubuntu 8.10 right now but it won't even allow me to mount it as a drive. I see /dev/sdb get added when I plug it in, but not sdb1 for the actual data so I can't mount it (tried formatting as FAT32 & 16). (Note: I had this working fine with a basic flash drive -- thats how I got adb on there to check for devices - which didn't find anything either. Also I had it working with some belkin wifi usb a few months ago). Now that I think about it I didn't try it with just a regular USB cable to see if at least the mounting works, even though I def need the data cable for the tethering. So does it have to be USB 2.0? Also do I need the drivers just to adb or mount it (I'm pretty sure the driver is just for the actual tethering though)?
Thanks in advance for any help.
cl0s said:
Do you need USB 2.0 for the tethering to work, or even just adb & mounting the G1 as a storage device? On my one laptop (w/ USB 2.0) I can adb into it fine, I have Ubuntu 8.10 and I never had to install any drivers (not manually at least), I never tried the tethering because I just do it through wireless using iptables -- if I ever need it.
The problem is with an older Toshiba laptop that has no NIC or wireless, I could get a dongle but I wanted to try changing the system wide proxy to go to the G1 once its plugged in -- make this into like my car PC or something. I only have a basic command line install of Ubuntu 8.10 right now but it won't even allow me to mount it as a drive. I see /dev/sdb get added when I plug it in, but not sdb1 for the actual data so I can't mount it (tried formatting as FAT32 & 16). (Note: I had this working fine with a basic flash drive -- thats how I got adb on there to check for devices - which didn't find anything either. Also I had it working with some belkin wifi usb a few months ago). Now that I think about it I didn't try it with just a regular USB cable to see if at least the mounting works, even though I def need the data cable for the tethering. So does it have to be USB 2.0? Also do I need the drivers just to adb or mount it (I'm pretty sure the driver is just for the actual tethering though)?
Thanks in advance for any help.
Click to expand...
Click to collapse
Did you try mounting /dev/sdb? It sounds like your sdcard has a raw fat filesystem, instead of having a partition formatted with fat. Also, you have to click "mount" in the usb notification thing that comes up on your phone after you plug it in.
JesusFreke said:
Did you try mounting /dev/sdb? It sounds like your sdcard has a raw fat filesystem, instead of having a partition formatted with fat. Also, you have to click "mount" in the usb notification thing that comes up on your phone after you plug it in.
Click to expand...
Click to collapse
I did mount it on the actual device. Also I tried formatting it twice with gParted, both times with the full disk as the partition, once as fat32 and second time fat16. When I tried to mount /dev/sdb all that came up was something about couldn't find the partitions and it echo'd out the error a couple of times before it stopped, I forget the exact error but I'll check when I get home. I tried to mount it both as dos and vfat, no luck on the Toshiba, doing it on my Vaio though it was fine, both command line and just letting Gnome pick it up.
Also on the Vaio as soon as I plug it in I get /dev/sdb and /dev/sdb1, but not on the Toshiba. The Vaio has Ubuntu Desktop Edition while the Toshiba has minimum command line install, but I believe it shouldn't need anything special to mount the fat16 drive.
I'll try with a regular USB cable and making sure I have whatever dependencies to read Windows partitions when I get home later on and see if that does anything different. Thanks anyway.
I'm not sure why you would even try to format the USB drive. Not useful.
When you plug in the device, you should see a device appear but that is not the sdcard. That will not be visible until you select the notification which appears on the device and choose to mount the drive. At this point, the sdcard will appear in dmesg and can be mounted from Linux.
For adb purposes (which is for tethering), you first need to get adb working right. The absolute first step there is to get the window version of adb away, away, away- GONE!- and make sure you have the linux verison installed. Next you need to create the udev rules. If you use any text editor, create a file in /tmp called 50-android.rules containing one line:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
and save it. The sudo mv that file to /etc/udev/rules.d, you should be good to go. I would restart udevd just for grins (sudo /etc/init.d/udev restart), then plug in your phone again and see what adb devices gives you, taking great care to use the linux version of adb.
DebauchedSloth said:
I'm not sure why you would even try to format the USB drive. Not useful.
When you plug in the device, you should see a device appear but that is not the sdcard. That will not be visible until you select the notification which appears on the device and choose to mount the drive. At this point, the sdcard will appear in dmesg and can be mounted from Linux.
For adb purposes (which is for tethering), you first need to get adb working right. The absolute first step there is to get the window version of adb away, away, away- GONE!- and make sure you have the linux verison installed. Next you need to create the udev rules. If you use any text editor, create a file in /tmp called 50-android.rules containing one line:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
and save it. The sudo mv that file to /etc/udev/rules.d, you should be good to go. I would restart udevd just for grins (sudo /etc/init.d/udev restart), then plug in your phone again and see what adb devices gives you, taking great care to use the linux version of adb.
Click to expand...
Click to collapse
Haha, trust me I have no Windows anything on any of my machines. I was planning on putting fluxbox or icewm on this so I can have rhythmbox, totem, browser, pyroute - some big icons with the windows set to open full screen so i can use in my car and script it to mount the drive for the music or movies and start tethering and possibly create something to pass over the gps info for navigation when plugged in. If I get it to work with this older/slower laptop I can then def recreate it or something later on with like a mini-itx/atom based pc and a small touchscreen or something (even though in that case I might be better off just putting Android on it). Really just to **** around ya know..
I was formatting just trying to get mounting to work, I def made sure to enable the mounting on the G1 before I tried it but it just wouldn't mount, "adb devices" wouldn't find anything, but you're right about dmesg echoing stuff, but it was errors, as soon as I clicked mount on the G1. I'll try creating that file like suggested and a few other things.
I'll return with more specifics on the errors when I try this out. Thanks for all the help though.
cl0s said:
Haha, trust me I have no Windows anything on any of my machines. I was planning on putting fluxbox or icewm on this so I can have rhythmbox, totem, browser, pyroute - some big icons with the windows set to open full screen so i can use in my car and script it to mount the drive for the music or movies and start tethering and possibly create something to pass over the gps info for navigation when plugged in. If I get it to work with this older/slower laptop I can then def recreate it or something later on with like a mini-itx/atom based pc and a small touchscreen or something (even though in that case I might be better off just putting Android on it). Really just to **** around ya know..
I was formatting just trying to get mounting to work, I def made sure to enable the mounting on the G1 before I tried it but it just wouldn't mount, "adb devices" wouldn't find anything, but you're right about dmesg echoing stuff, but it was errors, as soon as I clicked mount on the G1. I'll try creating that file like suggested and a few other things.
I'll return with more specifics on the errors when I try this out. Thanks for all the help though.
Click to expand...
Click to collapse
I just set this up on my vmplayer running ubuntu, I can use adb shell so the tetherbot app should work..

[Q] modify USB prompt / notification, how to choose which block device to publish ?

Hi all,
I searched the forum but find no answer for what I try to do, so let me ask this.
When I plug my phone (HTC Desire with Defrost 6.1a ROM) on to my laptop, the phone detects the USB connection and, I guess, launches an app that displays a prompt where I can activate USB Mass Storage.
If I choose "activate" the whole SDCard block device is published through the USB Mass Storage driver :
Code:
# cat /sys/devices/platform/usb_mass_storage/lun0/file
/dev/block/vold/179:0
Then, my Linux automount both partitions I have, the FAT and the EXT3, used by A2SD+. I wish only the FAT partition gets published. I tried Cyanogenmod just before the Defrost mod, and I remember that it did it.
So, I tried myself, through adb shell :
Code:
# echo "/dev/block/vold/179:1" > /sys/devices/platform/usb_mass_storage/lun0/file
Which does exactly what I need, publish only the FAT partition, so that my EXT3 partition is not accessible from my laptop.
Anyone knows a way to modify this default behaviour, application ? Any config file that I can edit ? to change the block device that gets published.
Even better, modify this default prompt to add more actions, like USB tethering. Something like the stock HTC prompt.
Jon.

[SOLVED] Infuse wont connect to Ubuntu....

UPDATE-SOLVED: So I used the terminal command dmesg to see what errors were coming up relating to the usb port. It turns out I was getting the popular "unable to enumerate usb device on port..." error. From a google search on this I was able to find other people with my same problem, albeit with other types of devices not working on the usb ports. So someone tried a simple fix and worked. Ill quote it here just for the sake of keeping you on this page...
Some hardware just don’t work with ehci_hcd on Karmic Koala. My memory stick from transcend refused to work no matter what I did. After plugging the device nothing happened, doing dmesg showed me the following error:
Apr 18 10:59:04 dpac-laptop kernel: [73668.388060] usb 1-2: new high speed USB device using ehci_hcd and address 5
Apr 18 10:59:04 dpac-laptop kernel: [73668.473034] hub 1-0:1.0: unable to enumerate USB device on port 2
After searching a lot, I came to a conclusion that my device doesn’t work with USB 2.0. So I disabled the ehci_hcd to make it work.
Since Karmic doesn’t use ehci_hcd as a module, modprobe -r ehci_hcd no longer works. The module is compiled into kernel. To disable it execute the following commands in terminal:
1: cd /sys/bus/pci/drivers/ehci_hcd
2: ls
You will see a file with 0000:00:xx.x format. Execute the following command:
1: sudo sh -c 'echo -n "0000:00:xx.x" > unbind'
#Replace the xx.x with the numbers displayed on your file. It should disable the ehci_hcd.
I plugged in my memory stick, and it worked.
Please note that you’ll have to do all this each time you restart.
UPDATE
You can now use the following script to disable ehci_hcd. It is far more simpler since it just needs you copy pasting the commands instead of a manual action. Here it goes:
1: cd /sys/bus/pci/drivers/ehci_hcd/
2: sudo sh -c 'find ./ -name "0000:00:*" -print| sed "s/\.\///">unbind'
Cheers!
Ok so I just finished installing a fresh copy of Ubuntu 11.04 on my g/f's old Sony Vaio from 2003/04. I tried plugging in the Infuse to see if the computer will recognize it. So when I select 'Mass storage' from the connection menu, the connect screen with the green android robot will pop up for a split second, then disappear. So there is no way for me to mount the phone to the computer. The option doesnt even appear in the notification bar. Sometimes the robot screen wont even appear at all. I check the cable, and it works 100% fine on my win 7 64 bit pc. It just doesnt seem to want to do anything on the Ubuntu pc. The phone will charge, but thats about it. Im running the clean Gingerbread update on the Infuse. Nothing modded, and as i said, the Ubuntu is clean install as well. Ive tried this with usb debugging on and off. Ive also tried restarting both phone and pc and nothing changes.
Any help would be so greatly appreciated. Thanks a million.
weird. try other USB devices. you could have motherboard driver issues.
I'd check the Ubuntu forums and see if others with that hardware have any issues with USB devices. you may need to find some alternative drivers that aren't in the stock Ubuntu build or find a different computer.
Dani897 said:
weird. try other USB devices. you could have motherboard driver issues.
I'd check the Ubuntu forums and see if others with that hardware have any issues with USB devices. you may need to find some alternative drivers that aren't in the stock Ubuntu build or find a different computer.
Click to expand...
Click to collapse
I have tried some flash drives. They seem to work just fine. When I plug the phone in under the mass storage option, I open up a terminal and type usb-devices, and i see the three ports listed, but it shows that nothing is being detected on any of them.
Linux driver should be perfect, before connects to PC the mass storage mode should be selected.
dubuntu said:
Linux driver should be perfect, before connects to PC the mass storage mode should be selected.
Click to expand...
Click to collapse
I made sure it was selected. I also just got finished setting up the Android SDK on the Ubuntu laptop. ADB does not recognize that the device is plugged in at all. It can see my flash drives, but nothing comes up for my phone. Even with usb debugging on it did not see it. Im at a loss. Im beginning to think that this may have something to do with the Gingerbread update. Can someone with the update try to connect to Ubuntu and let me know if they have success? Ide hate to have to revert my device to Froyo or an unofficial rom to develop. =/
well I see you fixed it. did you get adb going?
Dani897 said:
well I see you fixed it. did you get adb going?
Click to expand...
Click to collapse
Yes! How?
Sent from my SAMSUNG-SGH-I997 using Tapatalk
are you asking how he fixed it?(he updated the op if that's what you are interested in) or how to get adb going.? adb works on Ubuntu as long as the device connects but you need to setup some device information first.
I forget the location but you need to create a file called 70rules.android (if my memory serves me right) with the vendor I.d and some other information. let me know and ill find a link on it.
Yes! I was able to finally get adb going after I had fixed the USB detection. Once I had applied the changes above my computer would immediately recognize the phone in both normal and debug mode and I could transfer files to and from it freely. Also, typing in ./adb devices finally showed my device as being connected with the proper vendor id as well.
The file I believe yyour referring to is named 70-android.rules and its only part of a whole process on getting the sdk setup on the laptop. There are a lot of hits for setting g it up on Google. There is also a whole guide for this here on xda which I had followed.
Sent from my Samsung Silly Phone

How to access the BIOS on a Lenevo Tab S8-50 !

Thanks to @social-design-concepts , we are now able to access the UEFI Setup on the Lenovo Tab S8-50; In order to do that, you must first follow these steps:
Requirements :
1- A Computer, preferably windows.
2- A micro USB cable to plug the Tab into the computer.
3- You must have the proper ADB drivers installed.
Steps:
1- Make sure your Tablet has been rooted, and has at least 50 % battery life just in case.
2- Plug in your Tablet, and you should see a window open up on your tablet, which says to either connect as a Media Device, or a Camera. Make sure to check the Media option. Make sure to also check the box that says USB Debugging.
3- Once all those steps are completed, you must download the attached ADB file suite I compiled from the Android Developer Kit. It has no virus so don't worry.
4- Once the files are download, and you are sure your tablet is connected, extract the files to your desktop.
5- Open the up the extracted folder, which should be named as "adb", and press the Shift key on your keyboard, and right click anywhere until you see "Open command window here" option in the drop down menu.
6- You should see a command prompt window appear which says " c: \adb > "
7- you want to first type in " adb push efibootmgr32 /data/local/tmp/efibootmgr " without the quotation marks obviously.
8- Then you want to type in " adb shell "
9- If you did the previous step correctly the command line should change to " [email protected]:/ $ " or something like that.
10- After seeing that message, you want to then hit the space bar once after the $ sign and type in " cd /data/local/tmp "
11- Then it should look something like this " [email protected]:/data/local/tmp $ "
12- Simply type in the word " su " and it should change to " [email protected]:/data/local/tmp # "
13- You then need to type in " chmod 6755 efibootmgr " after the pound sign, just make sure there is one space between " chmod " and the #
14- Then, like the previous command, make sure there is one space between the pound sign and the command " ./efibootmgr -? " and once you type that in, you should see a long list appear.
15- Then after that you want to type in with the space between the # sign and this following command " ./efibootmgr -v "
16- Then you want in " ./efibootmgr -n 0001 "
17- Finally, you need to type in " reboot -p "
18- This will reboot your tablet, but you must manually turn it back on.
19- You will see a long list of random commands in yellow and white flash on your screen.
20- make sure you have a powered otg usb cable powered by a separate power source other then your tablet in order to connect a keyboard
21- Once that is plugged into your tablet, type in " exit "
22- you should be greeted by a white screen with a blue bar on top and a bunch of commands.
22- That is how you access the bios.
- You now have the option to modify many other options, such as disabling fast boot in order to install windows, allocate more gpu memory and so on.
- here is the link to the original link where you get a better view as to what the commands should look like.
http://forum.xda-developers.com/general/general/lenovo-tab-s8-50f-stock-firmware-rom-t2989791/page71
Hopefully this works. NOTE: I am not responsible for any damage that may be caused to your device.
Dobry den
mam lenovo tab s8-50l nejde boot failed. EFI hard drive help
Stupid me
I was messing with the options in the bios of the s8-50f, i have changed some of the settings and it no longer displays an image on the screen. I'm confident it is still working so does anyone know any key press during boot to reset the bios to defaults??
I can remember typing exit at the shell, moving down 3 to device manager and press enter and enter again. This should get onto the screen to load bios defaults but i can't remember the position of the option to load defaults or to commit changes.
Many thanks and sorry for wasting your valuable time.
Hi thanks a lot.
1. Is it possible to install Win 10 64 bit on this tablet? if so, then what about drivers like graphic?
2. is it possible to get into bios options page on each restart? maybe I want to change the boot option back to the Android.
regards
Josephx86 said:
Hi thanks a lot.
1. Is it possible to install Win 10 64 bit on this tablet? if so, then what about drivers like graphic?
2. is it possible to get into bios options page on each restart? maybe I want to change the boot option back to the Android.
regards
Click to expand...
Click to collapse
Don't I wish. There was not even enough dev support to get CM on this tablet when it was new, let alone years later. Most people have moved on, sadly. It is too bad because this device still has decent hardware and could probably be a decent device to multiboot droid and Windows. I had high hopes when it was first released that it could be used as a watered down surface with the ability to boot android.
I don't think it is impossible and I still have hope but hardly anyone even posts in the thread these days.
everything is right till step 19.what is wrong?
we turning on the device but the next step does not happened.
Keyboard
Hi, everything is fine but when i plug in micro usb with keyboard And turn on tablet some yellow commands are on the screen but i cant type , nothing happens. IT IS self powered , IT works in normal Android mode but not in that almost BIOS . Help me please
Mediatek devices can flashed with locked bootloader. Make a backup with SP Flash Tool. flash TWRP, then immediately boot into recovery. install SuperSU or Magisk
Completed all the steps, now whenever I restart tablet, I can't boot into android, it goes to the bios directly. Please some help?
hi, thanks, but where to download efibootmgr32?

how to clone device

Hello.
Is there a way to do copy of memory of entire device (settings of partition, datas on this partition...) I have two the same devices and I want to do exacly clone one to another.
I'm talking about lenovo tablets with MTK.
BR
My solution suggestion:
Both phone's Android must be rooted so all partitions can get accessed in R/W mode. A Windows computer with ADB installed on, an USB-hub with at least 2 ports is required.
You connect both phones at same time with Windows computer, you establish an ADB connection with both phones.
Then via a Windows command script you pull out complete contents of source phone and push back contents to target phone.

Categories

Resources