In my job, I work a lot with different android devices and interface with them using adb. Rather than remembering or needing to copy their serial numbers or IP addresses to refer to them, I've been trying to use aliases, but I'm running into issues. I'm currently using a combination of functions and profiles to refer to the devices. This is my current Profile.ps1 file:
function googletv_func ($params){
if ($params -eq "connect"){
adb connect 192.168.0.14
}
else{
adb -s 192.168.0.14 $params
}
}
function firehd_func ($params){
adb -s G0W1EW0 $params
}
Set-Alias googletv "googletv_func"
Set-Alias firehd "firehd_func"
If I enter the command "googletv connect", it will successfully connect to the google tv. But if I try something with more than one parameter following the alias (e.g. "googletv install example.apk" or "firehd shell pm list packages") it only executes the single parameter following the alias. Wondering what I'm missing and I appreciate anyone's help.
I am developing a security related app and would like to know when was the device previously factory reset? Is there any way to obtain this information?
I tried getting the last modified time for many files using the adb shell but some show 1970/1971/current date which is not consistent or accurate.
adb shell "stat /cache | grep Modify"
I know you said you tried getting modification time for some files, but the specific one you need to query is /cache.
The /cache folder is wiped when you factory reset your phone.
The command you would use is adb shell "stat /cache | grep Modify". Which produces something like: Modify: 2016-01-27 15:57:38.000000000
One way to achieve this is as follows:
adb devices -l
example output:
123abc12 device product:<id> model:<id> device:<id>
456abc45 device product:<id> model:<id> device:<id>
But this list's out all devices connected, but I want to get the information for a specific device.I want information only about "123abc12". The output should be:
123abc12 device product:<id> model:<id> device:<id>
The second device should not be shown.
I have the device name i.e 123abc12, and it can be used to get the required information, but I don't know how.
Thanks.
The correct way to do it would be:
adb -s 123abc12 shell getprop
Which will give you a list of all available properties and their values. Once you know which property you want, you can give the name as an argument to getprop to access its value directly, like this:
adb -s 123abc12 shell getprop ro.product.model
The details in adb devices -l consist of the following three properties: ro.product.name, ro.product.model and ro.product.device.
Note that ADB shell ends lines with \r\n, which depending on your platform might or might not make it more difficult to access the exact value (e.g. instead of Nexus 7 you might get Nexus 7\r).
Why don't you try to grep the return of your command ?
Something like :
adb devices -l | grep 123abc12
It should return only the line you want to.
Any command to know the MTU size of Android?
You should use the NetworkInterface class to query and obtain the network interfaces, then call getMTU().
Today, looking into the code of netcfg I saw that the configuration of the interfaces is located into /sys/class/net.. and then I thought of you! (I read your question yesterday)
If you have root access, open a terminal and run
cat /sys/class/net/<interface>/mtu
Methods to know the MTU size of Android:
from terminal: ifconfig $DEVICE | egrep addr\|MTU
through Android Debug Bridge (adb):
adb shell netcfg | grep UP to find the desired address and
adb shell ip addr show rmnet0 in case of rmnet0 or
adb shell cat /sys/class/net/rmnet0/mtu in case of rmnet0 (as described by #patedit)
Without ROOTING your phone, you may use a ping command from a Windows/Mac/Unix system. Though, the syntax of ping-options is very different for different OS.
For Windows
try this:
ping /l 1473 /f 10.68.34.75
/l <Size> — Specifies the length, in bytes, of the Data field in the echo Request messages sent. The default is 32.
/f — Specifies that echo Request messages are sent with the Do not Fragment flag in the IP header set to 1 (available on IPv4 only).
Adjust the payload using the -l command-line option. When you reach the higher limit, you will see this message and you will find the MTU size :
> The packet needs to be fragmented but DF set.
More details: https://kb.netgear.com/19863/Ping-Test-to-determine-Optimal-MTU-Size-on-Router
1480, I believe, but you can check by using ifconfig $DEVICE with a rooted device, and checking the MTU there.
For most network access, MTU could be resolved by MTU Discovery. You can use Ping command with different payload size and don't fragment to find aChrysler value. Good luck
Without ROOTING your phone, you may use a ping command from a Windows/Mac/Unix system. Though, the syntax of ping-options is very different for different OS.
From most Unix/Linux/Mac systems (Without ROOTING the phone)
You might share the internet connection from your phone, and then from any PC connected to your android-phone run ping commands:
ping www.yahoo.com -s 1413 -M do
man ping says:
-s <packetsize> — Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.
-M <pmtudisc_opt> — Select Path MTU Discovery strategy. <pmtudisc_option> may be either do (prohibit fragmentation, even local one), want (do PMTU discovery, fragment locally when packet size is large), or dont (do not set DF flag).
Adjust the payload using the -s command-line option (for example: 1200, 1300, 1400, 1500, 1450, 1425, 1440, ...). When you reach the higher limit, you will see a message like this and you will find the MTU size :
> From 192.168.1.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)
ping: local error: Message too long, mtu=1500
My answer is based on this one for windows: answer #25165641
My phone is having problem with sending data to the network. I think I have to change its MTU size to make it work.
To change MTU settings you need a to root your phone. Search in foruns how to do it.
After that your need to install a terminal emulator and check what is your network interface
Run the command:
netcfg
and look at the IP address what is your desired device (wlan0, tiwlan0, etc)
then use this command
ifconfig $DEVICE mtu $MTU_VALUE
and substitute $DEVICE with device name and the desired MTU value in $MTU_VALUE
You can also see the value at this file:
cat /sys/class/net/$DEVICE/mtu