Search code examples
androidmonkey

Will Monkey test occasionally enter settings and click the restart button to restart device?


When doing a Monkey test on android device, I send

adb shell monkey --ignore-security-exceptions --ignore-crashes --ignore-timeouts --ignore-native-crashes --throttle 200 -s 222 -v -v -v 125000 > c:\all_monkey.txt

then Monkey will send a lot of random event to device, I can see a lot of swipe screen or click button. Will Monkey occasionally enter settings and click the restart button to restart device? Because I found when running for a while, device will restart itself. Can I avoid Monkey test click restart button by itself. thanks.


Solution

  • Yes, you can wrap your restart function with this check from ActivityManager:

    if(!ActivityManager.isUserAMonkey()){
    //your code
    }
    

    isUserAMonkey ():

    Returns "true" if the user interface is currently being messed with by a monkey.

    Edit: since I misinterpreted the question the first time, here some maybe useful answers from so:

    -p flag

    adb shell monkey -p your.application.id.here //to restrict mokey to your application
    

    --pct-syskeys

    By setting the -pct-sysevents to zero. However the catch here is the order of events. - kopos