@@ -117,11 +117,12 @@ public class AndroidEntryPointCreator extends AbstractAndroidEntryPointCreator i
117117
118118 private SootField instantiatorField ;
119119
120- //Contains *all* potential component classes, irregular of whether
121- //they are defined in the manifest or not. Note that the app component
122- //factory might create other classes than those listed in the manifest, which makes
123- //everything quite complex.
124- //In other words, this set contains *all* possible components
120+ // Contains *all* potential component classes, irregular of whether
121+ // they are defined in the manifest or not. Note that the app component
122+ // factory might create other classes than those listed in the manifest, which
123+ // makes
124+ // everything quite complex.
125+ // In other words, this set contains *all* possible components
125126 private Set <SootClass > allComponentClasses = new HashSet <>();
126127
127128 private String getResultIntentName ;
@@ -160,7 +161,7 @@ public AndroidEntryPointCreator(IManifestHandler manifest, Collection<SootClass>
160161 }
161162 }
162163 getResultIntentName = findUniqueMethodName ("getResultIntent" , allComponentClasses );
163- //just choose a different name other than "getIntent"
164+ // just choose a different name other than "getIntent"
164165 getIntentName = findUniqueMethodName ("getDataIntent" , allComponentClasses );
165166 setIntentName = findUniqueMethodName ("setDataIntent" , allComponentClasses );
166167
@@ -210,6 +211,9 @@ protected SootMethod createDummyMainInternal() {
210211 // from previous runs
211212 reset ();
212213
214+ for (SootClass s : allComponentClasses ) {
215+ s .addInterface (componentDataExchangeInterface );
216+ }
213217 logger .info (String .format ("Creating Android entry point for %d components..." , components .size ()));
214218
215219 // For some weird reason unknown to anyone except the flying spaghetti
@@ -241,15 +245,16 @@ protected SootMethod createDummyMainInternal() {
241245 createIfStmt (beforeContentProvidersStmt );
242246 }
243247
244- // If the application tag in the manifest specifies a appComponentFactory, it needs to be called first
248+ // If the application tag in the manifest specifies a appComponentFactory, it
249+ // needs to be called first
245250 initializeApplComponentFactory ();
246251
247252 // If we have an implementation of android.app.Application, this needs
248253 // special treatment
249254 initializeApplicationClass ();
250255 Jimple j = Jimple .v ();
251256
252- //due to app component factories, that could be another application class!
257+ // due to app component factories, that could be another application class!
253258 SootClass applicationClassUse = Scene .v ().getSootClass (AndroidEntryPointConstants .APPLICATIONCLASS );
254259 ;
255260 // If we have an application, we need to start it in the very beginning
@@ -293,7 +298,7 @@ protected SootMethod createDummyMainInternal() {
293298 } else {
294299 // Create the application
295300 applicationLocal = generateClassConstructor (applicationClass );
296- //we know for sure that there is no other application class in question
301+ // we know for sure that there is no other application class in question
297302 applicationClassUse = applicationClass ;
298303 }
299304 localVarsForClasses .put (applicationClass , applicationLocal );
@@ -476,7 +481,6 @@ protected SootMethod createDummyMainInternal() {
476481 private void initializeComponentDataTransferMethods (ComponentExchangeInfo info ) {
477482
478483 for (SootClass s : allComponentClasses ) {
479- s .addInterface (s );
480484
481485 Scene sc = Scene .v ();
482486 Jimple j = Jimple .v ();
@@ -533,9 +537,9 @@ private void initializeComponentDataTransferMethods(ComponentExchangeInfo info)
533537 SootMethod setIntentMethod = sc .makeSootMethod (info .setIntentMethod .getName (),
534538 info .setIntentMethod .getParameterTypes (), info .setIntentMethod .getReturnType ());
535539 jb = j .newBody (setIntentMethod );
540+ setIntentMethod .setActiveBody (jb );
536541 s .addMethod (setIntentMethod );
537542 setIntentMethod .addTag (SimulatedCodeElementTag .TAG );
538- setIntentMethod .setActiveBody (jb );
539543 jb .insertIdentityStmts ();
540544 jb .getUnits ().add (j .newAssignStmt (j .newInstanceFieldRef (jb .getThisLocal (), intentField .makeRef ()),
541545 jb .getParameterLocal (0 )));
@@ -612,7 +616,7 @@ private void createJavascriptCallbacks() {
612616 f = mainMethod .getDeclaringClass ().getFieldByNameUnsafe (dm .getFieldName ());
613617 }
614618 if (f == null ) {
615- //create field
619+ // create field
616620 f = createField (arg .getType (), "jsInterface" );
617621 AssignStmt assign = j .newAssignStmt (j .newStaticFieldRef (f .makeRef ()), arg );
618622 assign .addTag (SimulatedCodeElementTag .TAG );
@@ -876,7 +880,8 @@ public void reset() {
876880 if (m != null && m .isDeclared ())
877881 sc .removeMethod (m );
878882 }
879- sc .removeInterface (componentDataExchangeInterface );
883+ if (sc .getInterfaces ().contains (componentDataExchangeInterface ))
884+ sc .removeInterface (componentDataExchangeInterface );
880885 }
881886
882887 // Get rid of the generated component methods
0 commit comments