Merge branch 'gingerbread' into gingerbread-release
This commit is contained in:
@@ -17,8 +17,8 @@
|
|||||||
package com.android.commands.monkey;
|
package com.android.commands.monkey;
|
||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.app.IActivityManager;
|
|
||||||
import android.app.IActivityController;
|
import android.app.IActivityController;
|
||||||
|
import android.app.IActivityManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.IPackageManager;
|
import android.content.pm.IPackageManager;
|
||||||
@@ -28,6 +28,7 @@ import android.os.Debug;
|
|||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.os.StrictMode;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
@@ -172,6 +173,9 @@ public class Monkey {
|
|||||||
|
|
||||||
long mDroppedFlipEvents = 0;
|
long mDroppedFlipEvents = 0;
|
||||||
|
|
||||||
|
/** The delay between user actions. This is for the scripted monkey. **/
|
||||||
|
long mProfileWaitTime = 5000;
|
||||||
|
|
||||||
/** a filename to the setup script (if any) */
|
/** a filename to the setup script (if any) */
|
||||||
private String mSetupFileName = null;
|
private String mSetupFileName = null;
|
||||||
|
|
||||||
@@ -222,8 +226,16 @@ public class Monkey {
|
|||||||
public boolean activityStarting(Intent intent, String pkg) {
|
public boolean activityStarting(Intent intent, String pkg) {
|
||||||
boolean allow = checkEnteringPackage(pkg) || (DEBUG_ALLOW_ANY_STARTS != 0);
|
boolean allow = checkEnteringPackage(pkg) || (DEBUG_ALLOW_ANY_STARTS != 0);
|
||||||
if (mVerbose > 0) {
|
if (mVerbose > 0) {
|
||||||
|
// StrictMode's disk checks end up catching this on
|
||||||
|
// userdebug/eng builds due to PrintStream going to a
|
||||||
|
// FileOutputStream in the end (perhaps only when
|
||||||
|
// redirected to a file?) So we allow disk writes
|
||||||
|
// around this region for the monkey to minimize
|
||||||
|
// harmless dropbox uploads from monkeys.
|
||||||
|
int savedPolicy = StrictMode.allowThreadDiskWrites();
|
||||||
System.out.println(" // " + (allow ? "Allowing" : "Rejecting") + " start of "
|
System.out.println(" // " + (allow ? "Allowing" : "Rejecting") + " start of "
|
||||||
+ intent + " in package " + pkg);
|
+ intent + " in package " + pkg);
|
||||||
|
StrictMode.setThreadPolicy(savedPolicy);
|
||||||
}
|
}
|
||||||
currentPackage = pkg;
|
currentPackage = pkg;
|
||||||
currentIntent = intent;
|
currentIntent = intent;
|
||||||
@@ -231,6 +243,7 @@ public class Monkey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean activityResuming(String pkg) {
|
public boolean activityResuming(String pkg) {
|
||||||
|
int savedPolicy = StrictMode.allowThreadDiskWrites();
|
||||||
System.out.println(" // activityResuming(" + pkg + ")");
|
System.out.println(" // activityResuming(" + pkg + ")");
|
||||||
boolean allow = checkEnteringPackage(pkg) || (DEBUG_ALLOW_ANY_RESTARTS != 0);
|
boolean allow = checkEnteringPackage(pkg) || (DEBUG_ALLOW_ANY_RESTARTS != 0);
|
||||||
if (!allow) {
|
if (!allow) {
|
||||||
@@ -240,12 +253,14 @@ public class Monkey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentPackage = pkg;
|
currentPackage = pkg;
|
||||||
|
StrictMode.setThreadPolicy(savedPolicy);
|
||||||
return allow;
|
return allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean appCrashed(String processName, int pid,
|
public boolean appCrashed(String processName, int pid,
|
||||||
String shortMsg, String longMsg,
|
String shortMsg, String longMsg,
|
||||||
long timeMillis, String stackTrace) {
|
long timeMillis, String stackTrace) {
|
||||||
|
int savedPolicy = StrictMode.allowThreadDiskWrites();
|
||||||
System.err.println("// CRASH: " + processName + " (pid " + pid + ")");
|
System.err.println("// CRASH: " + processName + " (pid " + pid + ")");
|
||||||
System.err.println("// Short Msg: " + shortMsg);
|
System.err.println("// Short Msg: " + shortMsg);
|
||||||
System.err.println("// Long Msg: " + longMsg);
|
System.err.println("// Long Msg: " + longMsg);
|
||||||
@@ -253,6 +268,7 @@ public class Monkey {
|
|||||||
System.err.println("// Build Changelist: " + Build.VERSION.INCREMENTAL);
|
System.err.println("// Build Changelist: " + Build.VERSION.INCREMENTAL);
|
||||||
System.err.println("// Build Time: " + Build.TIME);
|
System.err.println("// Build Time: " + Build.TIME);
|
||||||
System.err.println("// " + stackTrace.replace("\n", "\n// "));
|
System.err.println("// " + stackTrace.replace("\n", "\n// "));
|
||||||
|
StrictMode.setThreadPolicy(savedPolicy);
|
||||||
|
|
||||||
if (!mIgnoreCrashes) {
|
if (!mIgnoreCrashes) {
|
||||||
synchronized (Monkey.this) {
|
synchronized (Monkey.this) {
|
||||||
@@ -265,8 +281,10 @@ public class Monkey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int appNotResponding(String processName, int pid, String processStats) {
|
public int appNotResponding(String processName, int pid, String processStats) {
|
||||||
|
int savedPolicy = StrictMode.allowThreadDiskWrites();
|
||||||
System.err.println("// NOT RESPONDING: " + processName + " (pid " + pid + ")");
|
System.err.println("// NOT RESPONDING: " + processName + " (pid " + pid + ")");
|
||||||
System.err.println(processStats);
|
System.err.println(processStats);
|
||||||
|
StrictMode.setThreadPolicy(savedPolicy);
|
||||||
synchronized (Monkey.this) {
|
synchronized (Monkey.this) {
|
||||||
mRequestAnrTraces = true;
|
mRequestAnrTraces = true;
|
||||||
mRequestDumpsysMemInfo = true;
|
mRequestDumpsysMemInfo = true;
|
||||||
@@ -444,18 +462,18 @@ public class Monkey {
|
|||||||
if (mScriptFileNames != null && mScriptFileNames.size() == 1) {
|
if (mScriptFileNames != null && mScriptFileNames.size() == 1) {
|
||||||
// script mode, ignore other options
|
// script mode, ignore other options
|
||||||
mEventSource = new MonkeySourceScript(mRandom, mScriptFileNames.get(0), mThrottle,
|
mEventSource = new MonkeySourceScript(mRandom, mScriptFileNames.get(0), mThrottle,
|
||||||
mRandomizeThrottle);
|
mRandomizeThrottle, mProfileWaitTime);
|
||||||
mEventSource.setVerbose(mVerbose);
|
mEventSource.setVerbose(mVerbose);
|
||||||
|
|
||||||
mCountEvents = false;
|
mCountEvents = false;
|
||||||
} else if (mScriptFileNames != null && mScriptFileNames.size() > 1) {
|
} else if (mScriptFileNames != null && mScriptFileNames.size() > 1) {
|
||||||
if (mSetupFileName != null) {
|
if (mSetupFileName != null) {
|
||||||
mEventSource = new MonkeySourceRandomScript(mSetupFileName, mScriptFileNames,
|
mEventSource = new MonkeySourceRandomScript(mSetupFileName, mScriptFileNames,
|
||||||
mThrottle, mRandomizeThrottle, mRandom);
|
mThrottle, mRandomizeThrottle, mRandom, mProfileWaitTime);
|
||||||
mCount++;
|
mCount++;
|
||||||
} else {
|
} else {
|
||||||
mEventSource = new MonkeySourceRandomScript(mScriptFileNames, mThrottle,
|
mEventSource = new MonkeySourceRandomScript(mScriptFileNames, mThrottle,
|
||||||
mRandomizeThrottle, mRandom);
|
mRandomizeThrottle, mRandom, mProfileWaitTime);
|
||||||
}
|
}
|
||||||
mEventSource.setVerbose(mVerbose);
|
mEventSource.setVerbose(mVerbose);
|
||||||
mCountEvents = false;
|
mCountEvents = false;
|
||||||
@@ -638,6 +656,9 @@ public class Monkey {
|
|||||||
mSetupFileName = nextOptionData();
|
mSetupFileName = nextOptionData();
|
||||||
} else if (opt.equals("-f")) {
|
} else if (opt.equals("-f")) {
|
||||||
mScriptFileNames.add(nextOptionData());
|
mScriptFileNames.add(nextOptionData());
|
||||||
|
} else if (opt.equals("--profile-wait")) {
|
||||||
|
mProfileWaitTime = nextOptionLong("Profile delay" +
|
||||||
|
" (in milliseconds) to wait between user action");
|
||||||
} else if (opt.equals("-h")) {
|
} else if (opt.equals("-h")) {
|
||||||
showUsage();
|
showUsage();
|
||||||
return false;
|
return false;
|
||||||
@@ -1108,7 +1129,8 @@ public class Monkey {
|
|||||||
usage.append(" [--port port]\n");
|
usage.append(" [--port port]\n");
|
||||||
usage.append(" [-s SEED] [-v [-v] ...]\n");
|
usage.append(" [-s SEED] [-v [-v] ...]\n");
|
||||||
usage.append(" [--throttle MILLISEC] [--randomize-throttle]\n");
|
usage.append(" [--throttle MILLISEC] [--randomize-throttle]\n");
|
||||||
usage.append(" COUNT");
|
usage.append(" [--profile-wait MILLISEC]\n");
|
||||||
|
usage.append(" COUNT\n");
|
||||||
System.err.println(usage.toString());
|
System.err.println(usage.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,16 +48,16 @@ public class MonkeySourceRandomScript implements MonkeyEventSource {
|
|||||||
* @param random The random number generator.
|
* @param random The random number generator.
|
||||||
*/
|
*/
|
||||||
public MonkeySourceRandomScript(String setupFileName, ArrayList<String> scriptFileNames,
|
public MonkeySourceRandomScript(String setupFileName, ArrayList<String> scriptFileNames,
|
||||||
long throttle, boolean randomizeThrottle, Random random) {
|
long throttle, boolean randomizeThrottle, Random random, long profileWaitTime) {
|
||||||
if (setupFileName != null) {
|
if (setupFileName != null) {
|
||||||
mSetupSource = new MonkeySourceScript(random, setupFileName, throttle,
|
mSetupSource = new MonkeySourceScript(random, setupFileName, throttle,
|
||||||
randomizeThrottle);
|
randomizeThrottle, profileWaitTime);
|
||||||
mCurrentSource = mSetupSource;
|
mCurrentSource = mSetupSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String fileName: scriptFileNames) {
|
for (String fileName: scriptFileNames) {
|
||||||
mScriptSources.add(new MonkeySourceScript(random, fileName, throttle,
|
mScriptSources.add(new MonkeySourceScript(random, fileName, throttle,
|
||||||
randomizeThrottle));
|
randomizeThrottle, profileWaitTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
mRandom = random;
|
mRandom = random;
|
||||||
@@ -72,8 +72,8 @@ public class MonkeySourceRandomScript implements MonkeyEventSource {
|
|||||||
* @param random The random number generator.
|
* @param random The random number generator.
|
||||||
*/
|
*/
|
||||||
public MonkeySourceRandomScript(ArrayList<String> scriptFileNames, long throttle,
|
public MonkeySourceRandomScript(ArrayList<String> scriptFileNames, long throttle,
|
||||||
boolean randomizeThrottle, Random random) {
|
boolean randomizeThrottle, Random random, long profileWaitTime) {
|
||||||
this(null, scriptFileNames, throttle, randomizeThrottle, random);
|
this(null, scriptFileNames, throttle, randomizeThrottle, random, profileWaitTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -106,6 +106,8 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
|
|
||||||
private static final String EVENT_KEYWORD_TAP = "Tap";
|
private static final String EVENT_KEYWORD_TAP = "Tap";
|
||||||
|
|
||||||
|
private static final String EVENT_KEYWORD_PROFILE_WAIT = "ProfileWait";
|
||||||
|
|
||||||
// a line at the end of the header
|
// a line at the end of the header
|
||||||
private static final String STARTING_DATA_LINE = "start data >>";
|
private static final String STARTING_DATA_LINE = "start data >>";
|
||||||
|
|
||||||
@@ -113,6 +115,8 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
|
|
||||||
private static int LONGPRESS_WAIT_TIME = 2000; // wait time for the long
|
private static int LONGPRESS_WAIT_TIME = 2000; // wait time for the long
|
||||||
|
|
||||||
|
private long mProfileWaitTime = 5000; //Wait time for each user profile
|
||||||
|
|
||||||
FileInputStream mFStream;
|
FileInputStream mFStream;
|
||||||
|
|
||||||
DataInputStream mInputStream;
|
DataInputStream mInputStream;
|
||||||
@@ -126,9 +130,10 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
* @param throttle The amount of time in ms to sleep between events.
|
* @param throttle The amount of time in ms to sleep between events.
|
||||||
*/
|
*/
|
||||||
public MonkeySourceScript(Random random, String filename, long throttle,
|
public MonkeySourceScript(Random random, String filename, long throttle,
|
||||||
boolean randomizeThrottle) {
|
boolean randomizeThrottle, long profileWaitTime) {
|
||||||
mScriptFileName = filename;
|
mScriptFileName = filename;
|
||||||
mQ = new MonkeyEventQueue(random, throttle, randomizeThrottle);
|
mQ = new MonkeyEventQueue(random, throttle, randomizeThrottle);
|
||||||
|
mProfileWaitTime = profileWaitTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -350,6 +355,14 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Handle the profile wait time
|
||||||
|
if (s.indexOf(EVENT_KEYWORD_PROFILE_WAIT) >= 0) {
|
||||||
|
MonkeyWaitEvent e = new MonkeyWaitEvent(mProfileWaitTime);
|
||||||
|
mQ.addLast(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle keypress events
|
// Handle keypress events
|
||||||
if (s.indexOf(EVENT_KEYWORD_KEYPRESS) >= 0 && args.length == 1) {
|
if (s.indexOf(EVENT_KEYWORD_KEYPRESS) >= 0 && args.length == 1) {
|
||||||
String key_name = args[0];
|
String key_name = args[0];
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ void PropertyServer::SetDefaultProperties(void)
|
|||||||
{ "ro.HOME_APP_MEM", "4096" },
|
{ "ro.HOME_APP_MEM", "4096" },
|
||||||
{ "ro.BACKUP_APP_ADJ", "2" },
|
{ "ro.BACKUP_APP_ADJ", "2" },
|
||||||
{ "ro.BACKUP_APP_MEM", "4096" },
|
{ "ro.BACKUP_APP_MEM", "4096" },
|
||||||
|
{ "ro.PERCEPTIBLE_APP_ADJ", "2" },
|
||||||
|
{ "ro.PERCEPTIBLE_APP_MEM", "4096" },
|
||||||
|
{ "ro.HEAVY_WEIGHT_APP_ADJ", "3" },
|
||||||
|
{ "ro.HEAVY_WEIGHT_APP_MEM", "4096" },
|
||||||
//{ "init.svc.adbd", "running" }, // causes ADB-JDWP
|
//{ "init.svc.adbd", "running" }, // causes ADB-JDWP
|
||||||
{ "init.svc.usbd", "running" },
|
{ "init.svc.usbd", "running" },
|
||||||
{ "init.svc.debuggerd", "running" },
|
{ "init.svc.debuggerd", "running" },
|
||||||
|
|||||||
Reference in New Issue
Block a user