Skip to content

Commit 3acac54

Browse files
committed
fixed a broken component filter
1 parent 6662438 commit 3acac54

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

soot-infoflow-android/src/soot/jimple/infoflow/android/callbacks/filters/ApplicationCallbackFilter.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.Set;
44

5+
import soot.FastHierarchy;
6+
import soot.RefType;
57
import soot.Scene;
68
import soot.SootClass;
79
import 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
}

soot-infoflow-android/src/soot/jimple/infoflow/android/entryPointCreators/AndroidEntryPointUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class AndroidEntryPointUtils {
2121

2222
private static final Logger logger = LoggerFactory.getLogger(AndroidEntryPointUtils.class);
2323

24-
private Map<SootClass, ComponentType> componentTypeCache = new HashMap<SootClass, ComponentType>();
24+
private Map<SootClass, ComponentType> componentTypeCache = new HashMap<>();
2525

2626
private SootClass osClassApplication;
2727
private SootClass osClassActivity;

0 commit comments

Comments
 (0)