I am trying to make integration tests which test Fingerprint.
According to google doc to invoke finger touch on emulator from terminal you need to use:
adb -e emu finger touch < finger_id >
And this works for me. In my case id is 45146572. However in test you cannot input this command on your own as it should be done automatically.
I've been trying various things to make a workaround (eg. trying to understand how app is receiving information from sensor - maybe by some kind of broadcast intent etc.) and for now I still don't know how to do it.
I know that UiAutomation and UiAutomator's class - UiDevice has method
executeShellCommand
and I think that this might be helpful. But even if I do something like:
getUiDevice().executeShellCommand("-e emu finger touch 45146572");
My device won't react to it (I've tried on both classes and various threads). I believe this is caused by the fact executeShellCommand is running already inside shell. So it's like I've typed to terminal
Kamils-MacBook-Pro:~ F1sherKK$ adb shell
root#generic_x86_64:/ #
And I guess that's the problem, because google wants:
adb -e emu finger touch
not
adb shell -e emu finger touch
My knowledge about shell might be not enough maybe. I've looked through all documentation many times.
Do you have any idea how to call finger touch from shell?
I believe you have to be using different format of password. It should be "aa11aa" which is LetterLetterNumberNumberLetterLetter.
Related
In my app, I am using Timber as a logger. I am accessing the logs from the terminal via adb using this isntruction:
./adb logcat com.company.my_app:D
I do get the logs but the issue is that I am getting a crazy amount of noise from the OS (ie SurfaceFlinger , GraphicBuffer, vndksupport) which make the logs harder to read.
Is there a way to filter the logs like in Android Studio and just get logs from my app. Thank you !
P.S. I have trie a few answers from here but none of them remove the noise.
What works best for me is to grep for the process ID which is displayed in every log line. In the example below 7098 is printed with every log line.
08-10 18:48:39.825 7098 7144 D NetworkModule: --> END POST
So this is the adb instruction used to get filtered logs:
adb logcat | grep -F "7098"
Note: the process ID is not static and it is going to change if app is hard-closed or device is restarted.
I don't know if it is the best solution, but it works in my case.
I need to forward a port on an android emulator, right now I had to type the command every time:
adb forward tcp:23946 tcp:23946
Is there any way to make this automatic? I tried to replace adb with a script but that command won't work until the device is up and running.
Any ideas?
Based on this answer (which I've tested and works, though it wasn't for a scenario like this one), you could simply write a script that waits until the emulator is booted.
Something like (pseudocode, don't know which platform you're on) :)
emulator #emulator-name
while ('adb shell getprop init.svc.bootanim' == "running") sleep(10s)
adb forward tcp:23946 tcp:23946
I am building an Android application that is designed to help with load testing. When the app launches we are sending extra values to the main activity so that we can control what kind of load each app executes. Currently, we are doing this, scripted, via the terminal using adb directly which is pretty straight forward:
adb shell am start -e key1 value1 -e key2 value2 -n bla.bla/bla.MainActivity
For debugging purposes, I'd like to be able to do this from IntelliJ but I don't see anything in my run configuration screen that let's me pass anything to adb. Is this possible?
Might be waaaaaay late on this one, but you can always try the BashSupport plugin on the IntelliJ Repo.
I need to test an Android application that takes multi-touch input, such as pinch and rotate. I'd like to test this using the emulator if possible. Is there a way to send Linux input events, via ADB or otherwise, without modifying the Android source?
https://source.android.com/devices/tech/input/touch-devices.html
Events such as ABS_MT_POSITION_X, ABS_MT_POSITION_Y, and ABS_MT_TRACKING_ID.
Old question but still open.
Indeed there are options:
1.) Send commands via telnet (https://developer.android.com/studio/run/emulator-console)
2.) Use adb like (input tap X Y), e.g.
adb shell input tap 100 100
I already posted similar question, but still could not get my job done, so this a a second attempt, where
I would like to more clearly state my stumbling block.
So basically I am in Android phone's adb shell, communicating with the GPRS modem by sending AT commands.
I am able to do it by redirecting at command to the device file representing the modem; and I can read back
the response using cat utility running on the background (started earlier). I implemented it in a script
which can send a single AT command and read back the response. For example, here is the script to
send at+cops? to get the name of the operator the mobile is camping on:
#SendATCommand script
cat /dev/pts/7 &
echo -e at+cops?\\r > /dev/pts/7
The output looks as follows:
# ./sendATCommand
./sendATCommand
#
+COPS: 0,0,"AT&T",6
OK
/dev/pts/7: invalid length
Now here are two problems which I cannot resolve:
I still need to manually press ENTER button to get back adb shell prompt "#". Is there a way to return
to "#" prompt programmatically? Again, I am in adb shell.
The displayed response cannot be captured, neither in a variable, nor in file, (such as(#./sendATCommand > output.txt) Output.txt file will be empty. I tried various redirections, but still did not get it to work.
Can anyone please help me resolve those two problems (if ever possible)? Ultimately I want this little script to be
called from a "super" script (e.g. Perl or Powershell) running on PC to which my Android device is
connected, but there is no way to do it until those two problems resolved. Thanks a lot in advance!
I suggest that you try out my atinout program which should be exactly what you are asking for: a program to send AT commands from the command line and capture the output.
In your case the result should be like
$ echo 'at+cops?' | atinout - /dev/pts/7 -
+COPS: 0,0,"AT&T",6
OK
$
and to capture the output just put a file name instead of the last -.
I had similar problems with redirecting output to file. I resolved my problem by adding CMD /c in front of the echo command. I.e. if I understand correctly you need to tell the system that it needs to wait until command finishes executing and only then redirect output to a file. I was doing it in DOS.
Since you are running on ANDROID try adding sh -c in front of your command. Hope it helps.