Open an android application via shell command in python script - android

So I have a python script to test an android app with the monkeyrunner tool and at a certain point in the script, I have command to launch the application on the mobile phone. The command is: device.shell('monkey -p com.blah.blah -v 500') and it works perfect. But my question is: "What is the meaning of the number 500?"
I found this command on a forum and some users are using the value 300 instead of 500 or other values.. For me it works with all of them but not without it. I just need to understand what the number does so I can fully understand what I do.

As per Android Documentation this command will launch your application and send 500/300/200(as specified by you) pseudo-random events to it such as clicks, touches, or gestures.

Related

Android SMS limit on Android 4.0.4

I am working with phone with Android 4.0.4 (I know, the old one)
Now I need to override limit of 100 sms send per hour (Below android 4.1 there should be limit 100 sms per hour. Since android 4.1 there is limit 30 sms per 30 minutes).
Since Android 4.2 it is possible via adb shell settings put global sms_outgoing_check_max_count.
But I have no idea how to do it on Android 4.0.4 without rooting because there is no "adb shell settings" command. Any idea?
P.S. I am not creating app. I need to override this limit ideally in android settings via adb or by using another app for this (if it exists)
You could do it by creating the application and overriding the SmsUsageMonitor:
com.android.internal.telephony.SmsUsageMonitor
It should basically work on any phone, without rooting it first.
Could you try to follow theses steps via ADB :
1.Open Command Terminal
2.Type in adb shell hit enter
3.Type in su hit enter
4.Type in sqlite3 /data/data/com.android.providers.settings/databases/settings.db hit enter
5.Type in INSERT INTO secure (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
6.Type in INSERT INTO system (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
7.Type in .exit hit enter (you should now see a hash tag again instead of sqlite>. If not conitune typing in .exit and hitting enter until you are)
8.Type in sqlite3 /data/data/com.google.android.gsf/databases/gservices.db
9.Type in INSERT INTO main (name, value) VALUES('sms_outgoing_check_max_count’, 9999); hit enter
10.Again exit back to where the command line has a hashtag
11.Type in reboot and hit enter.
I don't have a phone with Android 4.0.4, so i can't confirm that it will work
Happy testing !
you have to use abd command to open that restrictions here is the link for tutorial change sms limit
1.Go to the android platform tool directory
`(C:\Users\username\AppData\Local\Android\Sdk\platform-tools)``enter code here`
open command shell by using Shift+mouserightclick and enter this command
adb shell settings put global sms_outgoing_check_max_count 5
settings put global sms_outgoing_check_interval_ms 9000000
I am actually reducing the number so Android warns me if I have sent more than 5 SMS messages within 30(9000000) minutes. Change “5” to whatever number you want
What exactly do you want to acheive with over 100 SMS per hour?
I am sure there is a way more efficient way of sending your data for example through
a wireless network or mobile data. You would hardly manage to reach the data limits of
those networks.
Just saying ... try only to do it over SMS if there really is NO other way of sending it.
Good luck!

AWS Device Farm - Pass parameters to a Robotium Test Script - Android

I want to automate the Robotium tests running on my Android application, however, I need to pass in parameters to my tests in order to allow them to run with that configuration.
I can start my tests from the command line as such:
adb shell am instrument -r -w -e PARAM PARAM_1,PARAM_2 com.company.product.application.test/android.support.test.runner.AndroidJUnitRunner
I grab these parameters as such in my code:
Bundle extras = InstrumentationRegistry.getArguments();
if (extras.containsKey("PARAM")) {
this.param1= new ArrayList<>();
this.param1= Arrays.asList(extras.getString("PARAM").split("\\s*,\\s*"));
}
I am intending to call the Device Farm API (https://docs.aws.amazon.com/devicefarm/latest/APIReference/Welcome.html) to run the tests, but I am struggling to find anywhere where I can declare my arguments/parameters. Or find a way of uploading them in a file somewhere in AWS for the Device farm to read from.
I have found some articles from 4-5 years ago claiming that passing launcher parameters was not supported but it was being looked into, in case some claim me lazy, but no one has responded to any questions there, or on the Amazon forums so I thought I would place the question here.
Can anyone help me with the above?
The tests are executed by Device Farm internally so there's no way to control the arguments that get sent to it when running, currently. However, it should be possible to include additional files which could hold that same info for the tests. Here are two ideas I have regarding this:
The tests could use the extra data feature of Device Farm. The extra data zip file gets uploaded to the /sdcard on the device. Then the tests could get the information from the device itself. This is part of the schedule run API so the script running the tests can do this programmatically.
There could be a file that's included in the test apk that's uploaded to Device Farm. I've done something similar with Java Appium tests but not with instumention. In theory it should work.
Other than that, I have not found other ways of including arguments or files for Device Farm.
Hth
-James

Open and interact with android application from command line

I've loaded Android onto VirtualBox and would like to do the following:
1) Via the command line (Terminal Emulator), open up a downloaded app (call it Lyft)
2) Interact with the app as if I were a user working with the app normally on a phone --
2a) Pass my username/password to log in
OR
2b) Pass in new account credentials to create a new account
I imagine this thing is possible, given that Android is just a modified version of Linux but I'm not entirely sure where to get started. How could one do this sort of thing to emulate the experience of using the mobile app, without an API and without actually touching a phone?
You can use AndroidViewClient/culebra to create a script that does all you want. culebra --gui can also be used to create the script just pointing and clicking on the UI (check https://github.com/dtmilano/AndroidViewClient/wiki/Culebra-GUI).
You can launch the app , but accessing input fields is possible if the login form fields request focus immediately after launching . Otherwise , an interaction to click on the form field is a must
For launching the app , go to the android sdk directory or if its added to the path - connect the phone and run
adb shell
adb shell monkey -p com.android.chrome -c android.intent.category.LAUNCHER 1
where com.android.chrome should be replaced by the package name of the app you want to launch

ADB shell script to send AT commands to a modem-cannot return control to a shell and capture output

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.

how can i use 'adb shell' command to know application response or current activity

I have created a batch file that fires adb shell command to start activity, send events to enter text into username and password text fields & click login buttons to navigate to other activity(screen).
how can i know that application navigate to other activity or want to know the response that tell me if login successful or not using shell commands.
Thanks,
Bhushan
Dollop, where I work, provides a record-and-play-back tool for Android that will do the things you suggest and save you the hassle of interacting with low-level shell commands. (It is currently limited to running on Windows in communication with Android devices). It's easy to configure and use, requires no programming, runs against real devices (which do NOT have to be rooted) and automatically saves screenshots as it plays tests. I'd love to hear your feedback.
try to get process (ps aux | grep xxxxx ) information to know the activity running or not

Categories

Resources