22
33import java .util .Set ;
44
5+ import soot .FastHierarchy ;
6+ import soot .RefType ;
57import soot .Scene ;
68import soot .SootClass ;
79import soot .SootMethod ;
@@ -21,6 +23,7 @@ public class ApplicationCallbackFilter extends AbstractCallbackFilter {
2123 private SootClass activityLifecycleCallbacks ;
2224 private SootClass provideAssistDataListener ;
2325 private SootClass componentCallbacks ;
26+ private SootClass componentCallbacks2 ;
2427
2528 /**
2629 * Creates a new instance of the {@link ApplicationCallbackFilter} class
@@ -65,12 +68,11 @@ public boolean accepts(SootClass component, SootClass callbackHandler) {
6568 // not implemented there
6669 if (this .applicationClass != null && component .getName ().equals (this .applicationClass )
6770 && !callbackHandler .getName ().equals (applicationClass )) {
68- if (!Scene .v ().getOrMakeFastHierarchy ().canStoreType (callbackHandler .getType (),
69- this .activityLifecycleCallbacks .getType ())
70- && !Scene .v ().getOrMakeFastHierarchy ().canStoreType (callbackHandler .getType (),
71- this .provideAssistDataListener .getType ())
72- && !Scene .v ().getOrMakeFastHierarchy ().canStoreType (callbackHandler .getType (),
73- this .componentCallbacks .getType ()))
71+ final FastHierarchy fh = Scene .v ().getOrMakeFastHierarchy ();
72+ final RefType callbackType = callbackHandler .getType ();
73+ if (!fh .canStoreType (callbackType , this .activityLifecycleCallbacks .getType ())
74+ && !fh .canStoreType (callbackType , this .provideAssistDataListener .getType ())
75+ && !fh .canStoreType (callbackType , this .componentCallbacks .getType ()))
7476 return false ;
7577 }
7678
@@ -84,6 +86,8 @@ public void reset() {
8486 this .provideAssistDataListener = Scene .v ()
8587 .getSootClassUnsafe ("android.app.Application$OnProvideAssistDataListener" );
8688 this .componentCallbacks = Scene .v ().getSootClassUnsafe (AndroidEntryPointConstants .COMPONENTCALLBACKSINTERFACE );
89+ this .componentCallbacks2 = Scene .v ()
90+ .getSootClassUnsafe (AndroidEntryPointConstants .COMPONENTCALLBACKS2INTERFACE );
8791 }
8892
8993 @ Override
@@ -92,10 +96,18 @@ public boolean accepts(SootClass component, SootMethod callback) {
9296 // components that are not the application
9397 if (component .getName ().equals (applicationClass ))
9498 return true ;
99+
95100 String subSig = callback .getSubSignature ();
96- return !AndroidEntryPointConstants .getActivityLifecycleCallbackMethods ().contains (subSig )
97- && !AndroidEntryPointConstants .getComponentCallbackMethods ().contains (subSig )
98- && !AndroidEntryPointConstants .getComponentCallback2Methods ().contains (subSig );
101+ final FastHierarchy fh = Scene .v ().getOrMakeFastHierarchy ();
102+ final RefType callbackType = callback .getDeclaringClass ().getType ();
103+ if (AndroidEntryPointConstants .getActivityLifecycleCallbackMethods ().contains (subSig ))
104+ return fh .canStoreType (callbackType , this .activityLifecycleCallbacks .getType ());
105+ if (AndroidEntryPointConstants .getComponentCallbackMethods ().contains (subSig ))
106+ return fh .canStoreType (callbackType , this .componentCallbacks .getType ());
107+ if (AndroidEntryPointConstants .getComponentCallback2Methods ().contains (subSig ))
108+ return fh .canStoreType (callbackType , this .componentCallbacks2 .getType ());
109+
110+ return true ;
99111 }
100112
101113}
0 commit comments