Setup
I'm on an Android 10 device and have an app (henceforth generator) that generates data it can copy to the device's clipboard (this involves swipes, taps, etc.). I need to do that repeatedly, as many times as possible (hundreds, thousands, whatever), and retrieve that data programmatically (presumably through a bash or perl script wrapped around adb commands).
Question
What would be some effective ways of achieving this?
Elaboration on what I've tried
I actually have a solution, I am just not sure it's the "best" one can do (whatever that means). generator is closed-source so I can't alter its behavior in any way, but I can repeatedly
start generator and/or switch focus to it with
adb shell monkey -p <generator-app> 1
mimic the tapping actions that produce the data and copy it to the clipboard with various
adb shell input tap x y
commands;
open/switch focus to the Termux terminal emulator (on the Android device):
adb shell monkey -p com.termux 1
access the clipboard via its Termux:API add-on, by running the termux-clipboard-get command in the termux terminal (again, on the Android device). I control this through adb with
adb shell input text 'termux-clipboard-get\>\>file-on-android-gadget.txt' && adb shell input keyevent 66
(keyevent 66 means ENTER, and the \>\> means append, >>, with escaped characters).
repeat the whole shebang.
This gives me many instances of the desired output in file-on-android-gadget.txt, saved locally on the phone (I'm OK retrieving it later, etc.).
Alternative routes?
What bothers me is the need to switch back and forth between two apps. I don't know that I have much choice over how I interact with generator, as it's closed-source and does not expose its internals, but perhaps one can do better at "the other end", i.e. when retrieving the clipboard data.
Newer Android APIs have locked down access to the clipboard, rendering it difficult to interact with programmatically, through adb. This SO thread points to a repo for a (Kotlin + gradle) app that sets the clipboard via a service runnable through adb, but my attempts to get the clipboard have been unsuccessful (i.e. getPrimaryClip() returns empty). I believe this is because, as per the docs:
getPrimaryClip
public ClipData getPrimaryClip ()
Returns the current primary clip on the clipboard. If the application
is not the default IME or does not have input focus this return null.
So there might just be no way around having to focus on a second app before the clipboard can be retrieved. But I have no experience programming apps, hence the question.
A further reference
During my peregrinations I found another repo for an Android app (Java + maven) that both gets and sets the clipboard. Same caveat though: as of Android 10, it needs to be in focus for the broadcast receiver to retrieve the clipboard data (other than that it works fine; I have it on my Android 10 device as we speak). So this would fare no better than my currently-working termux-based solution detailed above.
Related
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!
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.
At work, we have an Android-based infotainment system that we're constantly deploying new versions to, on a half-dozen different test benches. The deployment script does the moral equivalent of:
for apk in ${apk_files}; do
adb install -r ${apk]
done
After this, we need to manually execute the following steps:
Set the home app to be one of our just-installed applications (Always, not Just Once)
Become a developer, and enable the Stay Awake option
Select the Google TTS engine for text-to-speech functionality rather than Pico
Executing these steps after each deploy is a giant PITA. People often forget one or more steps, and leave the test bench in a non-working state. This results in a bunch of 'bogus' bug reports that waste everbody's time.
Is there some way (using adb, perhaps) that we can automate these steps?
You can disable other home apps with adb shell pm disable .... I don't think there's a command line option to set apps as default. I remember looking into this before and there was a "preferred application" XML file where this was stored. If you want to look into it, the magic happens in PackageManagerService.addPreferredActivityInternal(). Looks like it writes the data to a file on disk: package-restrictions.xml. I suppose it's possible you could figure out the format thereof and write the file (you'd need root).
This is controlled by a system settings, "stay_on_while_plugged_in". You can set it using adb shell settings system put ....
The TTS engine is stored in a secure setting, "tts_default_synth". You can see the value like,
$ adb shell settings get secure tts_default_synth com.svox.pico
com.svox.pico
And you can set it with adb shell settings put secure "tts_default_synth" <the value>.
I noticed that if the value was not been previously set, when you get the value using the settings command you get null and it's not listed in settings list, even though there is a default value. As of Android 6 (I think), settings are no longer in a DB but rather are stored in XML files in /data/system/users/0/settings_*.xml. You can see the values therein.
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 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