I'm working on script which suppose run CTS Tests on multiple devices.
unfortunately, while i check the serial number of my android devices I see that part of them contains identical serial number.
now, I read about an option to run adb devices -l to get usb entering of my devices, in order to I could run command on specific usb:
$ adb devices -l
List of devices attached
0123456789ABCDEF device usb:2-1.8
0123456789ABCDEF device usb:2-1.7
now, we can run this command on specific usb instead specific serial number as before:
$ adb -s usb:26200000 install xxx.apk
I want to do similar thing while I run CTS on specific android device:
$ ./cts-tradefed run cts -s usb:2-1.8 -p android.permission2
The problem is that it looks like the command not working. there isn't any response when I try this.
please, anybody can tell me if there is another way to run cts on specific device while there are two identical serial numbers?
There is another way of forcing adb to use a specific device besides -s parameter. You can assign your device id to the ANDROID_SERIAL environment variable. That works great for 3rd party scripts which do not support specifying the required id otherwise.
You can select between multiple devices you use the command list devices to get the serial of the devices:
l d
Example
cts-tf > l d
Serial State Allocation Product Variant Build Battery
10.1.1.113:5555 ONLINE Allocated product variant 2018.02.2 100
and then run cts with --serial parameter
run cts --serial <id>
where <id> is the first column in the result from l d command
Even if the parameter's name is serial in fact the value you give to it is the device id(as given by the command l d or list devices) and not the actual serial of the device.
Related
I have requirement like i need to take a UI dump of each window that appears on my android app to verify resource-id given is unique.
basically i want do what this command "adb shell uiautomator dump" does inside the android app.
#CommonsWare may be correct. But I tested the code below on two non-rooted devices and I was able to get an output. (Nexus 6P and Samsung S5)
#Gokul
I found the key was to NOT specify "adb shell" beforehand as it must be in the path already and I get a permission error if I attempt to use it.
Doing something like this:
String command = "service list";
Process process = Runtime.getRuntime().exec(command);
Worked for me running in a unit test on two real non-rooted devices.
This produces the same results as running the command: "adb shell service list" from the command prompt.
Im trying to install an apk on an specific emulator using TeamCity. Right now I`m starting an emulator an installing the apk successfully.. but if there is already one or more instances of the emulator running, team city cannot decide in which emulator install the apk (even when I'm starting the emulator from teamcity scripts).
The problem is that I cannot identify the emulator I just started using:
emulator -adv myEmulator
it will start an emulator between ports 5554 to 5587... I know I can set the emulator instance where I want to install my apk:
adb -s emulator-5554 install path/apk
but I don't know the id of the emulator I just started, so it could have any number in its name between that range.
I know I can set an UUID to the emulator (from here), but again.. don't know how to use that uuid.
Right now I will try to save the available emulators before I run my own using BATCH, and then compare both arrays to get my emulator.. but I'm not an expert on BATCH.. so if anyone has a clue it's gonna help,
Regards
You seem to look for -s option of adb:
-s <specific device> - directs command to the device or emulator with
the given serial number or qualifier.
other useful options:
-d - directs command to the only connected USB device
returns an error if more than one USB device is
present.
-e - directs command to the only running emulator.
returns an error if more than one emulator is
running.
and in general adb -h to see them all.
EDIT
You can define what port you want emulator to use:
-ports <consoleport>,<adbport> TCP ports used for the console and adb bridge
so you can assign ports manually and do not bother guessing. to avoid port collisions you can either force ports for all emulators launched (you should not have more than i.e. 3 running at the same time usually) or you can choose high port numbers for your range, high enough so even any other emulator is launched it will be using available ports below your range.
Alternatively you can parse emulator log produced when use with -verbose switch as you can find there:
emulator: control console listening on port 5554, ADB on port 5555
emulator: sent '0012host:emulator:5555' to ADB server
If you want to save emulator log to specific file, use regular stream redirection:
emulator -verbose #MyAVD > log.txt
I have next situation:
I got 2 version of adb and 2 versions of adbd on 2 different devices.
How can i use both versions of adb from my workstation for these 2 devices.
I mean:
1 adb for 1 device.
2 adb for 2 device.
Now i have following situation:
Every time when i run another adb, previous adb server kills and new one starts.
How can I workaround it?
I think you are asking the wrong question. What I think you want is to run two adb commands at once on different phones. Is that correct?
If so what you are looking for is
adb -s DEVICE_SERIAL xxx
where DEVICE_SERIAL is the value shown when you run adb devices and xxx is the command you want to run. Use adb devices for a list of connected devices.
This only requires you to have one version of adb installed, just open up a new terminal and run the command for the different serial numbered device!
If I'm understand the question correctly I believe he's trying to run two different versions of ADB at the same time. If my assumption is correct then here is what you'd want to do.
Lets assume you have adb.1.0.29.exe and adb.1.0.39.exe on the root of the c: drive which were renamed from the adb.exe from the different versions of platform-tools SDK versions they were supplied in.
To run the ADB version contained within adb.1.0.29.exe all you have to do is what the linked articles say BUT be sure to call the proper exe for that version. I used these adb version names as examples. You can name the adb.exe whatever you want.
So you can call adb commands with different versions as follows,
c:\adb.1.0.29.exe -s serial_of_device adb_command
or
c:\adb.1.0.23.exe -s serial_of_device adb_command
Cheers,
-Rob
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.
I'm planning to build an automated system for deploying an Android build to various devices, in order to make development for multiple platforms a bit more comfortable. Is there a way to get the sdk version of a connected device through android shell or adb?
There will be a computer to which several test devices is connected, and I was planning to write a script which will fetch the correct build for each of those from a build-server, install the different apks on their respective devices, launch them and collect log info, to be made available through some other program whose specifications are beside the point.
The point is that I need to know the sdk version each device is running to install the correct apk, and I was hoping I could get this through adb, but I can't seem to find a way to access it short of building a tiny app, compatible with all versions, whose sole purpose would be to output android.os.Build.VERSION.SDK or similar somewhere my script could read it.
you can use this command:
adb shell grep ro.build.version.sdk= system/build.prop
It will output something like this:
ro.build.version.sdk=10
adb shell getprop ro.build.version.sdk
Note #Tim: this works even on phones without grep support on all host OS :-). (i.e. on old phones where toolbox does not support grep you you need to have busybox on your phone).
I also discovered a way to get the exact version of Android e.g. 4.2.2 based on the following web article http://xayon.net/looking-for-android-version-with-adb/ You need to be using a unix-like operating system - Linux and Mac OSX are fine, and windows users can use cygwin or equivalent.
At a command line:
echo version=$(adb shell getprop |awk -F":" '/build.version.release/ { print $2 }')|tr -d '[]'
Here is the result for my Nexus 4:
version= 4.2.2
I think you can by accessing the device with adb shell - change directories to position you at system and do a cat of build.prop. Here you will find for instance, ro.build.description=google_sdk-eng 2.2, ro.build.version.release=2.2 etc