I know that it is possible to read and set the MTU during runtime e.g. with:
adb shell ip -d -s l l dev rmnet0
adb shell ifconfig rmnet0 mtu <MTU>
This has the problem that the MTU set this way does not hold after restarting the phone.
So how to configure the default MTU for an interface when building your own build with Android Open Source Project sources?
There seems to be no mention about this anywhere and grepping code does not seem to help. Also the default Linux kernel configuration files where this is done do not seem to exist in Android.
There sure must be a way to do this, right?
Apparently PMTUD is a better solution to this (RFC 4821).
It can be enabled in AOSP builds in init.rc (e.g. system/core/rootdir/init.rc) by adding following lines at the end of section "on boot":
on boot
# Other configurations here...
# Set TCP MTU Probing to automatic:
write /proc/sys/net/ipv4/tcp_mtu_probing 1
Related
For example If I am modifying something in
frameworks/base/media/java/android/media/AudioTrack.java then how should I build only related package and copy to target than building complete AOSP image. I can't use "adb sync" since my build is in remote machine.
Even just knowing what to copy will help after building all, than copying whole image
It's not easy to figure out which files may have been indirectly affected by your change. find /out/.../system -newer fileyouchanged.java should usually work, I think.
But...
I can't use "adb sync" since my build is in remote machine.
Use ssh forwarding to make adb sync (and adb in general) work over ssh.
From man ssh_config:
RemoteForward
Specifies that a TCP port on the remote machine be forwarded over
the secure channel. [...]
So, you'd put a RemoteForward 5037 localhost:5037 line in your ssh config file (e.g. ~/.ssh/config), preferably only for that specific host.
Super convenient!
(if it sometimes doesn't work, make sure that adbd is running on your local machine through adb start-server, and that it isn't running on the remote with adb kill-server.)
I am debugging C++ library for Android with GDB (gdbserver + gdb on host), and I've noticed that gdb output is very very slow.
E.g. application has about 15 threads, and when I type thread apply all bt it takes 15-20 seconds to output all stacktraces to terminal/file. All output is about 200 lines of text, it should not be that slow!
Moreover, on my host machine (64-bit Ubuntu) the same thing takes no more than 0.1-0.2 seconds!
I suspected that terminal output on host may be the cause of slowdown, but it is not the case. Even with the following settings it takes the same amount of time:
set width 0
set height 0
set pagination 0
set logging redirect on
set logging overwrite on
set logging file prof.txt
set logging on
I am not completely sure what is the main cause of slowdown, it is either slow stack unwinding on Android or slow transfer of data via gdb<-->gdbserver connection. But I am suspecting the latter, because when gdb outputs data the adb process consumes a lot of CPU time.
My question is: how do I make the gdb output to file faster?
Please help, if anyone knows how to achieve one of the following:
Set some gdb/adb options to make the data transfer faster
make gdbserver save data to local file (on Android device) instead of sending it to remote gdb client
Build gdb client for target device and debug on the device
EDIT:
It worth mentioning that I am using adb forward to establish tcp connection between gdb and gdbserver:
adb push $NDK_ROOT/prebuilt/android-arm/gdbserver/gdbserver /data/local/tmp
adb shell chmod 777 /data/local/tmp/gdbserver
adb shell /data/local/tmp/gdbserver :5039 --attach $1 &
adb forward tcp:5039 tcp:5039
I am using mux drivers for GSM modem with android 4.0.4 and I executes using command on console:
./gsm0710muxd -s /dev/ttyUSB0 -b 115200 -n 3
but I want to automate this, so I want to execute it during boot-up time so that my virtual ports may work with my gsm modem for calling functionalities but I am unable to automate this command, I have no idea how to do this because the command is complicated, I don't know how to use this as a whole to tell system serial port, baudrate, number of ports.
You can do this by giving this command in init.rc. Here is an example from init.rc. You can add this in the boot section of init.rc where other services are also initialized.
service gsmmuxd /system/bin/logwrapper /system/bin/gsm0710muxd –s /dev/<serial_port> –n3 -v7 –mbasic
class main
user radio
group radio cache inet misc
oneshot
Plus you will also need to change the device which is used in ril-daemon service. For instance, my RIL library is librapid-ril-core.so and I am using mux, the configuration would be the following:
service ril-daemon /system/bin/rild -l /system/lib/librapid-ril-core.so -- -a /dev/pts/0 -n /dev/pts/1
Here, if we were using USB, you would see /dev/ttyUSB0 and /dev/ttyUSB1 in your init.rc configurations.
I hope this helps. Please feel free to ask further questions.
I am trying to search if there is a way to disable android device usb port, software level mainly. So users can still charge android device but cannot communicate with PC anymore.
I got some clues in link1. But it looks there is not an easy way for this.
Android OS is a Linux based OS. So I am wondering if there is a config file in Android OS that allows root users to disable usb port, like files under path /etc in Linux OS.
EDIT: Use this command in android terminal emulator. Root priveleges required, but you can put a password on Superuser so that no one else can undo this or edit the script:
echo 0 > /sys/devices/virtual/android_usb/android0/enable
or...
su -c 'echo 0 > /sys/devices/virtual/android_usb/android0/enable'
To automate this, you need to make a script and put it in /system/etc/init.d, let's say /system/etc/init.d/usb_off:
#!/system/bin/sh
echo 0 > /sys/devices/virtual/android_usb/android0/enable
Then make sure it's executable with:
chmod +x /system/etc/init.d/usb_off
You can also try this, but it's reported not to work. Execute these in the command line via Android Terminal Emulator:
setprop persist.sys.usb.config ''
setprop sys.usb.config ''
You can tell the usb-storage module to ignore a VID/PID combination
Make a file such as /etc/modprobe.d/android.conf having contents of the form
options usb-storage quirks=vid##:pid##:i
Where the vid/pid are given in hex without prefix
A serious limitation of this technique is that some installations will load the usb-storage driver during the initread stage before /etc is present and honored, so it may get loaded without the ignore quirk. To work around that you can modify the inittread archive, or you can unload and reload the usb-storage module (if nothing else in your system is using it).
Another downside is that if you decide you want to mount it, you'd have to reload the driver without the quirk (for example using insmod).
I have a task at work to investigate if it is possible to send AT commands to an android device via ADB shell. So far,I have tried to echo out the AT commands but it passes them as normal strings.
Any help please anyone.
Please try this:
echo -e "AT+CFUN=?\r\n" > /dev/ttyUSB0
On your phone, the serial line must not necessarily be called ttyUSB0. If this is not working or not available, check out the other entries of the /dev/ directory.
So it could also be /dev/ttyGS0 or /dev/SMD0 (as found out by #Sani).
For further information, please check out this Guide
NOTE:
There might also be phones, that do not respond to AT commands on any of their serial (tty) devices.
I just tried my own procedure on a Samsung Galaxy S4 and did not have any success.
Echo them where? In Android you talk to the rild (Radio Interface Layer) daemon, which in turns talks to a proprietary library, which sends commands to the actual hardware. Check rild source code for details. You could probably write a command line program that talks to the rild and execute it via adb shell, if that fits your needs.
In order to find out which port to use :
You can check
# cat /proc/tty/drivers
Use logcat -b radio | grep dev to see wich tty the radio is using.
Yes you can run AT commands from adb shell too...
prerequsite :-
1. rooted android phone
2. you are aware of the port that RIL use for i/o operation.
3. to check which port is being used by RIl use `getprop rild.libargs`
To run AT command from ADB use:
echo -c "AT\r\n" > /dev/smd11
PS: smd11 is port used by RIL.This varies from device to device.
ALso to run AT commands from android application check this tutorial
http://tech-papers.org/executing-at-commands-android-application/
Kind of a combination of the above. We got it working with 2 terminals on a Pixel 4 XL.
On one we did:
cat /dev/smd7
in the other:
echo "AT\r" > /dev/smd7
The output shows up in the first terminal
Notes:
Have to be root!
None of the discovery mechanisms worked for us, so we blindly called into smdX until we got a response from "AT\r".
echo automatically adds a \n, so adding it is redundant.