I'm creating my own custom backup program that works through ADB in recovery mode. I've got a Nexus 4 using TeamWin Recovery Project (TWRP). My backup program uses reverse tethering and it's working great; however, it's a manual process to get the phone initially configured correctly, so now I'd like to automate the setup process.
First thing I did was push a quick reverse-tethering.sh startup script to the phone.
reverse-tethering.sh
#!/sbin/sh
echo 0 > /sys/devices/virtual/android_usb/android0/enable <--disables adb
... commands to enable reverse-tethering here ...
echo 1 > /sys/devices/virtual/android_usb/android0/enable <--enables adb
Here's where I'm running into problems. I'm trying to execute the reverse-tethering.sh script using the command:
adb shell /reverse-tethering.sh
My adb connection gets cut off and the remaining lines of the script are not executed after 0 is echoed to the file. :( Is there a way call a script through ADB and ensure that all of its lines get executed? I understand I will lose my ADB connection. I just want the script to continue executing even when I lose my connection.
As a side note, when I execute each line of the script individually through TWRP's command terminal, everything works fine.
Related
I want to enable the logging of some tags during the testing.
How can I execute
adb shell setprop log.tag.GAv4 DEBUG
on the firebase emulator ?
There's currently no way to execute arbitrary adb commands prior to a test in Firebase Test Lab. Feel free to file a feature request to indicate what you're trying to do.
Have you tried executeShellCommand?
https://developer.android.com/reference/android/app/UiAutomation#executeShellCommand(java.lang.String)
Executes a shell command. This method returns a file descriptor that points to the standard output stream. The command execution is similar to running "adb shell " from a host connected to the device.
(Reference: https://github.com/Flank/flank/issues/1808)
I have two c application running on android
say helloWorld and helloHell . I need to run both but with a reboot in between.
I have adb pushed the applications to a folder in android file system and created two scripts :
helloworld.sh and helloHell.sh
inside helloworld.sh :
./helloworld
reboot
inside helloHell.sh :
./helloHell
reboot
I have written a shell script on the host PC like this :
hell-world.sh
1->adb shell sh helloWorld.sh
2->some calculated delay
3->adb shell sh helloHell.sh
But the problem with this is after running first script (1->) the command hangs(may be due to reboot inside the helloworld.sh) and I have to manually do CTRL+C , and then manually run the second script(2->) once the reboot is over.
I even tried killing after the first script execution(1->) by doing something like this
PID =$!
kill -9 $PID
but invain,
My aim is to run both the applications with a reboot in between with no user intervention in between.The problem here is after the reboot no new command after that will be executed and have to terminate it manually.
Remove reboot from script file & try this
adb shell sh helloWorld.sh
adb shell reboot
# add some delay here
adb shell sh helloHell.sh
I have a rooted Android device and I need to pull everything to pc.
First try in DDMS File explorer did not work out, it hangs and has to be force closed.
Trying again in powershell with
adb pull /
skips "special files"
is there a way to pull everything including special files?
EDIT: I have tried booting in Engineer mode and Meta mode and I have tried to copy from shell
No success
2 things:
Try booting the phone into FastBoot and then do adb pull. Some of the files might be in use while the phone is running and causing them to be skipped.
I haven't done this personally, but I would try to use adb to get to shell on the phone and copy the files that were skipped.
adb shell
I'm trying to debug why my android mobile will not boot. When I run:
adb pull / e:\temp
It freezes at
pull: /proc/kmsg -> e:\temp/proc/kmsg
Is there some way to stop it freezing here or to get 'pull' to by-pass this file.
(I'm running this command while the phone is sitting in the recovery menu as I cant get adb to run in any other state).
Samsung Galaxy GT-i5500, android 2.2, windows 7.
You can instead dump the log using
adb logcat -d > log.txt
This will provide you with the log which you can use to debug the issue.
Run-time messages can be obtained through
adb shell dmesg
For kmsg, the following command can be tried.
adb shell cat /proc/kmesg
I have a little script that I run in adb shell of Android phone (/system/etc directory), which enables to communicate with the modem by sending/receiving a single AT command.
The script itself, if run in adb shell, works OK. That's what it looks like:
cat /dev/pts/7 &
echo -e $1\\r > /dev/pts/7
Here's the output in adb shell:
# ./sendATCommand "at+cops?"
./sendATCommand "at+cops?"
#
+COPS: 0,0,"AT&T",6
OK
/dev/pts/7: invalid length
(need to press ENTER to return control to adb shell)
#
Now I want to invoke this script from a powershell script running on my PC, thus eventually controlling modem via AT commands, but nothing happens.
For example, the below powershell script will send the command at+cops? to check the operator to which mobile is registered to:
$adb = [IO.Path]::Combine([IO.Path]::Combine($Env:ANDROID, "platform-tools"), "adb.exe")
& $adb remount
$atCommand = "at+cops?"
& $adb shell /system/etc/sendATCommand $atCommand
The output may looks sometimes like +ATCMD (any residual [proprietary]AT command sitting in device buffer after bootup), or at+cops?(echo), or nothing at all, but
never +COPS: 0,0,"AT&T",6 which I expect. Could you help me figure out what's going on and how to possibly fix it? Ideally
I want to be able to execute at command, return control to powershell, and have output available for further processing.
I am also open to other solutions to implement same thing.
Would greatly appreciate your help. Thanks!
Not sure to answer your question, my phone is not an Android, but when I connect it via buetooth or USB to my computer a COM port is created. So I build an assembly tool on the top of .NET SerialPort class that allow, for example, to send SMS using the phone Modem.
I think it's usable in your case.