@@ -127,6 +127,8 @@ public class AndroidEntryPointCreator extends AbstractAndroidEntryPointCreator i
127127
128128 private String getResultIntentName ;
129129
130+ private String setResultIntentName ;
131+
130132 private String getIntentName ;
131133
132134 private String setIntentName ;
@@ -136,6 +138,7 @@ public class AndroidEntryPointCreator extends AbstractAndroidEntryPointCreator i
136138 private SootClass componentDataExchangeInterface ;
137139
138140 private SootMethod getResultIntentMethod ;
141+ private SootMethod setResultIntentMethod ;
139142 private SootMethod getIntentMethod ;
140143 private SootMethod setIntentMethod ;
141144
@@ -161,6 +164,7 @@ public AndroidEntryPointCreator(IManifestHandler manifest, Collection<SootClass>
161164 }
162165 }
163166 getResultIntentName = findUniqueMethodName ("getResultIntent" , allComponentClasses );
167+ setResultIntentName = findUniqueMethodName ("setResultIntent" , allComponentClasses );
164168 // just choose a different name other than "getIntent"
165169 getIntentName = findUniqueMethodName ("getDataIntent" , allComponentClasses );
166170 setIntentName = findUniqueMethodName ("setDataIntent" , allComponentClasses );
@@ -177,17 +181,20 @@ private ComponentExchangeInfo generateComponentDataExchangeInterface() {
177181
178182 RefType intent = RefType .v ("android.content.Intent" );
179183 Scene sc = Scene .v ();
180- getResultIntentMethod = sc .makeSootMethod (getResultIntentName , Collections .emptyList (), intent );
184+ getResultIntentMethod = sc .makeSootMethod (getResultIntentName , Collections .emptyList (), intent ,
185+ Modifier .PUBLIC | Modifier .ABSTRACT );
181186 componentDataExchangeInterface .addMethod (getResultIntentMethod );
182- getResultIntentMethod .setModifiers (Modifier .PUBLIC | Modifier .ABSTRACT );
183- getIntentMethod = sc .makeSootMethod (getIntentName , Collections .emptyList (), intent );
184- getIntentMethod .setModifiers (Modifier .PUBLIC | Modifier .ABSTRACT );
187+ getIntentMethod = sc .makeSootMethod (getIntentName , Collections .emptyList (), intent ,
188+ Modifier .PUBLIC | Modifier .ABSTRACT );
185189 componentDataExchangeInterface .addMethod (getIntentMethod );
186- setIntentMethod = sc .makeSootMethod (setIntentName , Arrays .asList (intent ), VoidType .v ());
187- setIntentMethod . setModifiers ( Modifier .PUBLIC | Modifier .ABSTRACT );
190+ setIntentMethod = sc .makeSootMethod (setIntentName , Arrays .asList (intent ), VoidType .v (),
191+ Modifier .PUBLIC | Modifier .ABSTRACT );
188192 componentDataExchangeInterface .addMethod (setIntentMethod );
193+ setResultIntentMethod = sc .makeSootMethod (setResultIntentName , Arrays .asList (intent ), VoidType .v (),
194+ Modifier .PUBLIC | Modifier .ABSTRACT );
195+ componentDataExchangeInterface .addMethod (setResultIntentMethod );
189196 ComponentExchangeInfo info = new ComponentExchangeInfo (componentDataExchangeInterface , getIntentMethod ,
190- setIntentMethod , getResultIntentMethod );
197+ setIntentMethod , getResultIntentMethod , setResultIntentMethod );
191198 componentToInfo .setComponentExchangeInfo (info );
192199 return info ;
193200
@@ -214,9 +221,6 @@ protected SootMethod createDummyMainInternal() {
214221 // from previous runs
215222 reset ();
216223
217- for (SootClass s : allComponentClasses ) {
218- s .addInterface (componentDataExchangeInterface );
219- }
220224 logger .info (String .format ("Creating Android entry point for %d components..." , components .size ()));
221225
222226 // For some weird reason unknown to anyone except the flying spaghetti
@@ -237,7 +241,7 @@ protected SootMethod createDummyMainInternal() {
237241 // Conditionally call the onCreate method
238242 NopStmt thenStmt = Jimple .v ().newNopStmt ();
239243 createIfStmt (thenStmt );
240- searchAndBuildMethod (AndroidEntryPointConstants .CONTENTPROVIDER_ONCREATE , currentClass , localVal );
244+ searchAndBuildMethod (AndroidEntryPointConstants .CONTENTPROVIDER_ONCREATE , localVal );
241245 body .getUnits ().add (thenStmt );
242246 hasContentProviders = true ;
243247 }
@@ -337,8 +341,7 @@ protected SootMethod createDummyMainInternal() {
337341 }
338342
339343 // Call the onCreate() method
340- searchAndBuildMethod (AndroidEntryPointConstants .APPLICATION_ONCREATE , applicationClassUse ,
341- applicationLocal );
344+ searchAndBuildMethod (AndroidEntryPointConstants .APPLICATION_ONCREATE , applicationLocal );
342345
343346 //////////////
344347 // Initializes the ApplicationHolder static field with the
@@ -465,8 +468,7 @@ protected SootMethod createDummyMainInternal() {
465468
466469 // Add a call to application.onTerminate()
467470 if (applicationLocal != null )
468- searchAndBuildMethod (AndroidEntryPointConstants .APPLICATION_ONTERMINATE , applicationClassUse ,
469- applicationLocal );
471+ searchAndBuildMethod (AndroidEntryPointConstants .APPLICATION_ONTERMINATE , applicationLocal );
470472
471473 body .getUnits ().add (Jimple .v ().newReturnVoidStmt ());
472474
@@ -485,6 +487,7 @@ private void initializeComponentDataTransferMethods(ComponentExchangeInfo info)
485487
486488 for (SootClass s : allComponentClasses ) {
487489
490+ s .addInterface (componentDataExchangeInterface );
488491 Scene sc = Scene .v ();
489492 Jimple j = Jimple .v ();
490493
@@ -500,7 +503,8 @@ private void initializeComponentDataTransferMethods(ComponentExchangeInfo info)
500503 resultIntentField .addTag (SimulatedCodeElementTag .TAG );
501504 s .addField (resultIntentField );
502505 SootMethod getResultIntentMethod = sc .makeSootMethod (info .getResultIntentMethod .getName (),
503- info .getResultIntentMethod .getParameterTypes (), info .getResultIntentMethod .getReturnType ());
506+ info .getResultIntentMethod .getParameterTypes (), info .getResultIntentMethod .getReturnType (),
507+ Modifier .PUBLIC );
504508 getResultIntentMethod .addTag (SimulatedCodeElementTag .TAG );
505509 JimpleBody jb = j .newBody (getResultIntentMethod );
506510 getResultIntentMethod .setActiveBody (jb );
@@ -525,20 +529,32 @@ private void initializeComponentDataTransferMethods(ComponentExchangeInfo info)
525529 intentField .addTag (SimulatedCodeElementTag .TAG );
526530 s .addField (intentField );
527531
532+ SootMethod setResultIntentMethod = sc .makeSootMethod (info .setResultIntentMethod .getName (),
533+ info .setResultIntentMethod .getParameterTypes (), info .setResultIntentMethod .getReturnType (),
534+ Modifier .PUBLIC );
535+
536+ jb = j .newBody (setResultIntentMethod );
537+ setResultIntentMethod .setActiveBody (jb );
538+ s .addMethod (setResultIntentMethod );
539+ setResultIntentMethod .addTag (SimulatedCodeElementTag .TAG );
540+ jb .insertIdentityStmts ();
541+ jb .getUnits ().add (j .newAssignStmt (j .newInstanceFieldRef (jb .getThisLocal (), resultIntentField .makeRef ()),
542+ jb .getParameterLocal (0 )));
543+ jb .getUnits ().add (j .newReturnVoidStmt ());
528544 SootMethod getIntentMethod = sc .makeSootMethod (info .getIntentMethod .getName (),
529- info .getIntentMethod .getParameterTypes (), info .getIntentMethod .getReturnType ());
545+ info .getIntentMethod .getParameterTypes (), info .getIntentMethod .getReturnType (), Modifier . PUBLIC );
530546 jb = j .newBody (getIntentMethod );
531547 getIntentMethod .addTag (SimulatedCodeElementTag .TAG );
532548 getIntentMethod .setActiveBody (jb );
533549 s .addMethod (getIntentMethod );
534550 jb .insertIdentityStmts ();
535- lcl = j .newLocal ("ret " , getIntentMethod .getReturnType ());
551+ lcl = j .newLocal ("retValue " , getIntentMethod .getReturnType ());
536552 jb .getLocals ().add (lcl );
537553 jb .getUnits ().add (j .newAssignStmt (lcl , j .newInstanceFieldRef (jb .getThisLocal (), intentField .makeRef ())));
538554 jb .getUnits ().add (j .newReturnStmt (lcl ));
539555
540556 SootMethod setIntentMethod = sc .makeSootMethod (info .setIntentMethod .getName (),
541- info .setIntentMethod .getParameterTypes (), info .setIntentMethod .getReturnType ());
557+ info .setIntentMethod .getParameterTypes (), info .setIntentMethod .getReturnType (), Modifier . PUBLIC );
542558 jb = j .newBody (setIntentMethod );
543559 setIntentMethod .setActiveBody (jb );
544560 s .addMethod (setIntentMethod );
@@ -877,16 +893,6 @@ public MultiMap<SootClass, SootMethod> getCallbackFunctions() {
877893 public void reset () {
878894 super .reset ();
879895
880- for (SootClass sc : allComponentClasses ) {
881- for (String mn : new String [] { getIntentName , getResultIntentName }) {
882- SootMethod m = sc .getMethodByNameUnsafe (mn );
883- if (m != null && m .isDeclared ())
884- sc .removeMethod (m );
885- }
886- if (sc .getInterfaces ().contains (componentDataExchangeInterface ))
887- sc .removeInterface (componentDataExchangeInterface );
888- }
889-
890896 // Get rid of the generated component methods
891897 for (SootMethod sm : getAdditionalMethods ()) {
892898 if (sm .isDeclared ())
0 commit comments