package uk.ac.cam.gpe21.droidssl.analysis;

import soot.Pack;
import soot.PackManager;
import soot.Transform;
import soot.options.Options;

import java.util.Arrays;

public final class StaticAnalyser {
	public static void main(String[] args) {
		Options.v().set_src_prec(Options.src_prec_apk);
		Options.v().set_output_format(Options.output_format_none);
		Options.v().set_android_jars("/opt/android/platforms");
		Options.v().set_process_dir(Arrays.asList("test-hv/build/apk/test-hv-release-unsigned.apk"));

		/*
		 * We configure Soot with the Options class and then call its main()
		 * method with an empty arguments array. Enabling unfriendly mode stops
		 * Soot from printing the help because of the empty arguments array.
		 */
		Options.v().set_unfriendly_mode(true);

		Pack jtp = PackManager.v().getPack("jtp");
		jtp.add(new Transform("jtp.jsse_hostname_verifier", new JsseHostnameVerifierTransformer()));
		jtp.add(new Transform("jtp.httpclient_hostname_verifier", new HttpClientHostnameVerifierTransformer()));
		jtp.add(new Transform("jtp.default_jsse_hostname_verifier", new DefaultJsseHostnameVerifierTransformer()));

		soot.Main.main(new String[0]);
	}
}

@@ -53,60 +53,9 @@
 oot.
-Pack;%0Aimport soot.PackManager;%0Aimport soot.Transform
+*
 ;%0Aim
@@ -106,16 +106,38 @@
 .Arrays;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -208,16 +208,55 @@
 args) %7B%0A
+%09%09/*%0A%09%09 * Set path to input APK.%0A%09%09 */%0A
 %09%09Option
@@ -297,16 +297,174 @@
 c_apk);%0A
+%09%09Options.v().set_process_dir(Arrays.asList(%22test-hv/build/apk/test-hv-release-unsigned.apk%22));%0A%0A%09%09/*%0A%09%09 * Prevent Soot from outputting *.jimple files.%0A%09%09 */%0A
 %09%09Option
@@ -515,16 +515,66 @@
 t_none);
+%0A%0A%09%09/*%0A%09%09 * Set the path to the Android SDK.%0A%09%09 */
 %0A%09%09Optio
@@ -628,373 +628,248 @@
 %22);%0A
-%09%09Options.v().set_process_dir(Arrays.asList(%22test-hv/build/apk/test-hv-release-unsigned.apk%22)
+%0A%09%09/*%0A%09%09 * Enable the SPARK points-to analysis.%0A%09%09 */%0A%09%09Options.v().set_whole_program(true
 );%0A
-%0A
 %09%09
-/*%0A%09%09 * We configure Soot with the Options class and then call its main()%0A%09%09 * method with an empty arguments array. Enabling unfriendly mode stops%0A%09%09 * Soot from printing the help because of the empty arguments array.%0A%09%09 */%0A%09%09Options.v().set_unfriendly_mode(true);%0A
+PhaseOptions.v().processPhaseOptions(%22cg.spark%22, %22enabled:true,verbose:true%22);%0A%0A%09%09/*%0A%09%09 * Add transforms to the Jimple Transformation Pack.%0A%09%09 */
 %0A%09%09P
@@ -1229,36 +1229,461 @@
 %0A%0A%09%09
-soot.Main.main(new String%5B0%5D
+/*%0A%09%09 * Add transforms for the Whole Jimple Transformation Pack.%0A%09%09 */%0A%09%09Pack wjtp = PackManager.v().getPack(%22wjtp%22);%0A%09%09wjtp.add(new Transform(%22wjtp.print_call_graph%22, new SceneTransformer() %7B%0A%09%09%09@Override%0A%09%09%09protected void internalTransform(String s, Map%3CString, String%3E stringStringMap) %7B%0A%09%09%09%09System.err.print(Scene.v().getCallGraph());%0A%09%09%09%7D%0A%09%09%7D));%0A%0A%09%09/*%0A%09%09 * Perform the analysis.%0A%09%09 */%0A%09%09Scene.v().loadNecessaryClasses();%0A%09%09PackManager.v().runPacks(
 );%0A%09

Add points-to analysis.