summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNetta Peterbursky <nettap@google.com>2017-08-29 10:20:02 -0700
committerNetta Peterbursky <nettap@google.com>2017-08-29 10:20:02 -0700
commitd46f37edbc2749c0c27a1fd3fab438b73c87fd4a (patch)
tree86f78fe93fe0369cf2d31ef0a869479d70b2d9c2
parent45d91a062c40a7fe8ad56debc6224028ee2d40b0 (diff)
downloaddevelopment-d46f37edbc2749c0c27a1fd3fab438b73c87fd4a.tar.gz
Fix NullPointerException in Monkey.
Change-Id: Ibfeb2e68826d8aff748a02cd8bd1c3c3991f9127 Fixes: b/65113577 Test: adb shell monkey -p com.android.calculator2 -p com.android.launcher -p com.google.android.launcher -p com.android.mms -p com.android.phone -p com.google.android.dialer -p com.android.providers.downloads.ui -p com.android.settings -p com.google.android.gms -p com.google.android.setupwizard -p com.google.android.packageinstaller -p com.google.android.apps.nexuslauncher -c android.intent.category.LAUNCHER --ignore-security-exceptions --monitor-native-crashes -s 19 -v -v -v 125000
-rw-r--r--cmds/monkey/src/com/android/commands/monkey/Monkey.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
index d206a00a3..3b1e39b46 100644
--- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java
+++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
@@ -260,7 +260,7 @@ public class Monkey {
*/
private class ActivityController extends IActivityController.Stub {
public boolean activityStarting(Intent intent, String pkg) {
- boolean allow = isActivityStartingAllowed(intent, pkg);
+ final boolean allow = isActivityStartingAllowed(intent, pkg);
if (mVerbose > 0) {
// StrictMode's disk checks end up catching this on
// userdebug/eng builds due to PrintStream going to a
@@ -287,8 +287,10 @@ public class Monkey {
}
// In case the activity is launching home and the default launcher
// package is disabled, allow anyway to prevent ANR (see b/38121026)
+ final Set<String> categories = intent.getCategories();
if (intent.getAction() == Intent.ACTION_MAIN
- && intent.getCategories().contains(Intent.CATEGORY_HOME)) {
+ && categories != null
+ && categories.contains(Intent.CATEGORY_HOME)) {
try {
final ResolveInfo resolveInfo =
mPm.resolveIntent(intent, intent.getType(), 0, UserHandle.myUserId());