@@ -194,21 +194,27 @@ protected SootMethod generateRedirectMethodForStartActivityForResult(SootClass o
194194 Local intentParameterLocal = lg .generateLocal (INTENT_TYPE );
195195 b .getUnits ().add (Jimple .v ().newIdentityStmt (intentParameterLocal , Jimple .v ().newParameterRef (INTENT_TYPE , 1 )));
196196
197+ Value arIntentLocal ;
197198 // call onCreate
198- Local componentLocal = lg .generateLocal (destComp .getType ());
199- {
200- SootMethod targetDummyMain = componentToEntryPoint .getEntryPoint (destComp );
201- if (targetDummyMain == null )
202- throw new RuntimeException (
203- String .format ("Destination component %s has no dummy main method" , destComp .getName ()));
204- b .getUnits ().add (Jimple .v ().newAssignStmt (componentLocal , Jimple .v ()
205- .newStaticInvokeExpr (targetDummyMain .makeRef (), Collections .singletonList (intentParameterLocal ))));
206- }
199+ if (destComp != null ) {
200+ Local componentLocal = lg .generateLocal (destComp .getType ());
201+ {
202+ SootMethod targetDummyMain = componentToEntryPoint .getEntryPoint (destComp );
203+ if (targetDummyMain == null )
204+ throw new RuntimeException (
205+ String .format ("Destination component %s has no dummy main method" , destComp .getName ()));
206+ b .getUnits ().add (Jimple .v ().newAssignStmt (componentLocal , Jimple .v ().newStaticInvokeExpr (
207+ targetDummyMain .makeRef (), Collections .singletonList (intentParameterLocal ))));
208+ }
207209
208- // Get the activity result
209- Local arIntentLocal = lg .generateLocal (INTENT_TYPE );
210- b .getUnits ().add (Jimple .v ().newAssignStmt (arIntentLocal , Jimple .v ().newInterfaceInvokeExpr (componentLocal ,
211- componentToEntryPoint .getComponentExchangeInfo ().getResultIntentMethod .makeRef ())));
210+ // Get the activity result
211+ arIntentLocal = lg .generateLocal (INTENT_TYPE );
212+ b .getUnits ().add (Jimple .v ().newAssignStmt (arIntentLocal , Jimple .v ().newInterfaceInvokeExpr (componentLocal ,
213+ componentToEntryPoint .getComponentExchangeInfo ().getResultIntentMethod .makeRef ())));
214+ } else {
215+ //Nonetheless, we want to have onActivityResult in the call graph.
216+ arIntentLocal = NullConstant .v ();
217+ }
212218
213219 // some apps do not have an onActivityResult method even they use
214220 // startActivityForResult to communicate with other components.
0 commit comments