From e96443e5a7b37d4922b709d55a4ea55f401b7c98 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Wed, 18 Apr 2018 15:43:50 -0400 Subject: [PATCH] Make Instrumentation more robust to other inputs Test: atest cts/tests/app/src/android/app/cts/InstrumentationTest.java Change-Id: I2d55274ab19c4687ce85c086f2da61a4316b8096 Fixes: 70720100 --- core/java/android/app/Instrumentation.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index d42fb4cbd512c..c7618fe62c870 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -1210,11 +1210,16 @@ public class Instrumentation { Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - String pkg = intent.getComponent().getPackageName(); + String pkg = intent != null && intent.getComponent() != null + ? intent.getComponent().getPackageName() : null; return getFactory(pkg).instantiateActivity(cl, className, intent); } private AppComponentFactory getFactory(String pkg) { + if (pkg == null) { + Log.e(TAG, "No pkg specified, disabling AppComponentFactory"); + return AppComponentFactory.DEFAULT; + } if (mThread == null) { Log.e(TAG, "Uninitialized ActivityThread, likely app-created Instrumentation," + " disabling AppComponentFactory", new Throwable());