|
2 | 2 |
|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.util.ArrayList; |
5 | | -import java.util.Collection; |
6 | | -import java.util.Collections; |
7 | 5 | import java.util.HashSet; |
8 | 6 | import java.util.Iterator; |
9 | 7 | import java.util.List; |
|
26 | 24 | import soot.jimple.infoflow.android.callbacks.filters.ICallbackFilter; |
27 | 25 | import soot.jimple.infoflow.android.entryPointCreators.AndroidEntryPointConstants; |
28 | 26 | import soot.jimple.infoflow.android.entryPointCreators.AndroidEntryPointUtils; |
29 | | -import soot.jimple.infoflow.android.entryPointCreators.AndroidEntryPointUtils.ComponentType; |
30 | 27 | import soot.jimple.infoflow.memory.IMemoryBoundedSolver; |
31 | 28 | import soot.jimple.infoflow.memory.ISolverTerminationReason; |
32 | 29 | import soot.jimple.infoflow.util.SystemClassHandler; |
@@ -97,7 +94,7 @@ protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") |
97 | 94 | break; |
98 | 95 |
|
99 | 96 | List<MethodOrMethodContext> methods = new ArrayList<MethodOrMethodContext>( |
100 | | - getLifecycleMethods(sc)); |
| 97 | + entryPointUtils.getLifecycleMethods(sc)); |
101 | 98 |
|
102 | 99 | // Check for callbacks registered in the code |
103 | 100 | analyzeRechableMethods(sc, methods); |
@@ -155,77 +152,6 @@ protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") |
155 | 152 | PackManager.v().getPack("wjtp").add(transform); |
156 | 153 | } |
157 | 154 |
|
158 | | - /** |
159 | | - * Gets all lifecycle methods in the given entry point class |
160 | | - * |
161 | | - * @param sc The class in which to look for lifecycle methods |
162 | | - * @return The set of lifecycle methods in the given class |
163 | | - */ |
164 | | - private Collection<? extends MethodOrMethodContext> getLifecycleMethods(SootClass sc) { |
165 | | - return getLifecycleMethods(entryPointUtils.getComponentType(sc), sc); |
166 | | - } |
167 | | - |
168 | | - /** |
169 | | - * Gets all lifecycle methods in the given entry point class |
170 | | - * |
171 | | - * @param componentType the component type |
172 | | - * @param sc The class in which to look for lifecycle methods |
173 | | - * @return The set of lifecycle methods in the given class |
174 | | - */ |
175 | | - public static Collection<? extends MethodOrMethodContext> getLifecycleMethods(ComponentType componentType, |
176 | | - SootClass sc) { |
177 | | - switch (componentType) { |
178 | | - case Activity: |
179 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getActivityLifecycleMethods()); |
180 | | - case Service: |
181 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getServiceLifecycleMethods()); |
182 | | - case Application: |
183 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getApplicationLifecycleMethods()); |
184 | | - case BroadcastReceiver: |
185 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getBroadcastLifecycleMethods()); |
186 | | - case Fragment: |
187 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getFragmentLifecycleMethods()); |
188 | | - case ContentProvider: |
189 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getContentproviderLifecycleMethods()); |
190 | | - case GCMBaseIntentService: |
191 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getGCMIntentServiceMethods()); |
192 | | - case GCMListenerService: |
193 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getGCMListenerServiceMethods()); |
194 | | - case ServiceConnection: |
195 | | - return getLifecycleMethods(sc, AndroidEntryPointConstants.getServiceConnectionMethods()); |
196 | | - case Plain: |
197 | | - return Collections.emptySet(); |
198 | | - } |
199 | | - return Collections.emptySet(); |
200 | | - } |
201 | | - |
202 | | - /** |
203 | | - * This method takes a lifecycle class and the list of lifecycle method |
204 | | - * subsignatures. For each subsignature, it checks whether the given class or |
205 | | - * one of its superclass overwrites the respective methods. All findings are |
206 | | - * collected in a set and returned. |
207 | | - * |
208 | | - * @param sc The class in which to look for lifecycle method |
209 | | - * implementations |
210 | | - * @param methods The list of lifecycle method subsignatures for the type of |
211 | | - * component that the given class corresponds to |
212 | | - * @return The set of implemented lifecycle methods in the given class |
213 | | - */ |
214 | | - private static Collection<? extends MethodOrMethodContext> getLifecycleMethods(SootClass sc, List<String> methods) { |
215 | | - Set<MethodOrMethodContext> lifecycleMethods = new HashSet<>(); |
216 | | - SootClass currentClass = sc; |
217 | | - while (currentClass != null) { |
218 | | - for (String sig : methods) { |
219 | | - SootMethod sm = currentClass.getMethodUnsafe(sig); |
220 | | - if (sm != null) |
221 | | - if (!SystemClassHandler.v().isClassInSystemPackage(sm.getDeclaringClass().getName())) |
222 | | - lifecycleMethods.add(sm); |
223 | | - } |
224 | | - currentClass = currentClass.hasSuperclass() ? currentClass.getSuperclass() : null; |
225 | | - } |
226 | | - return lifecycleMethods; |
227 | | - } |
228 | | - |
229 | 155 | private void analyzeRechableMethods(SootClass lifecycleElement, List<MethodOrMethodContext> methods) { |
230 | 156 | // Make sure to exclude all other edges in the callgraph except for the |
231 | 157 | // edges start in the lifecycle methods we explicitly pass in |
|
0 commit comments