Running app on android

During my research on android malwares, I faced an issue of running the malware on android (emulator) which I used 2 methods depends on the situation.

In case you need to only run the app and you do not care about what happenes next, you can use “am” command,

adb shell am start -n package/.activity

You can find out the package/activity name by refering to my previous post and find more about android activity manager here

On the other hand, if you need to poke the app to imitate (somehow) the real user, Monkey will do the job for you.

adb shell monkey -s 10 --throttle 1000 --pct-touch 100 -p %s 20 > /dev/null &

To find more info about Monkey please refer to my previous post here or here.

Advertisements

Running app on android

During my research on android malwares, I faced an issue of running the malware on android (emulator) which I used 2 methods depends on the situation.

In case you need to only run the app and you do not care about what happenes next, you can use “am” command,

adb shell am start -n package/.activity

You can find out the package/activity name by refering to my previous post and find more about android activity manager here

On the other hand, if you need to poke the app to imitate (somehow) the real user, Monkey will do the job for you.

adb shell monkey -s 10 --throttle 1000 --pct-touch 100 -p %s 20 > /dev/null &

To find more info about Monkey please refer to my previous post here or here.

Stability control of Android Monkey behavior

I had a problem with Android Monkey which the Monkey mimicked random patterns of events while this behavior prevent my system’s results to be same all the time. The fact is that by default Monkey sends pseudo-random stream of user events to the system. This behaviar may cause difficulties for developers who wants to practice a series of expected user events with the least randomization.

Well, it is possible to define the randomization seed which can almost trigger similar sequence of actions. In addition you can decide what types of event (Touche, Motion, Trackball or Navigation) are going to be send.

For example

adb shell monkey s 10 --pct-touch 60 --pct-motion 40 -p com.android.app 200

will send 200 events to the app which contains 60% touch and 40% motion events to the system while the variables are using randomized values with the define seed of 10.

In my own case, I used an additional time interval to make it even more predictable as:

adb shell monkey -s 10 --throttle 1000 --pct-touch 100 -p com.android.app 20

which will send 20 event with intervals of 1000ms. This makes it easier to predict what is going on with the system so we can perform automated debugging in more convenient way (in this case you can expect a run time of 20 seconds in which one touch will be send every second).

Monkey Reference: http://developer.android.com/tools/help/monkey.html

Stability control of Android Monkey behavior

I had a problem with Android Monkey which the Monkey mimicked random patterns of events while this behavior prevent my system’s results to be same all the time. The fact is that by default Monkey sends pseudo-random stream of user events to the system. This behaviar may cause difficulties for developers who wants to practice a series of expected user events with the least randomization.

Well, it is possible to define the randomization seed which can almost trigger similar sequence of actions. In addition you can decide what types of event (Touche, Motion, Trackball or Navigation) are going to be send.

For example

adb shell monkey s 10 --pct-touch 60 --pct-motion 40 -p com.android.app 200

will send 200 events to the app which contains 60% touch and 40% motion events to the system while the variables are using randomized values with the define seed of 10.

In my own case, I used an additional time interval to make it even more predictable as:

adb shell monkey -s 10 --throttle 1000 --pct-touch 100 -p com.android.app 20

which will send 20 event with intervals of 1000ms. This makes it easier to predict what is going on with the system so we can perform automated debugging in more convenient way (in this case you can expect a run time of 20 seconds in which one touch will be send every second).

Monkey Reference: http://developer.android.com/tools/help/monkey.html