Skip to content

Commit 88f0796

Browse files
committed
Fixed issues #2(apk by parameter), #3(generate jar with rip2), #4(outputfolder as parameter)
1 parent 7e8ef2a commit 88f0796

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repositories {
1919

2020
task jarjar(type: Jar) {
2121
manifest {
22-
attributes "Main-Class": "main.Rip"
22+
attributes "Main-Class": "main.Rip2"
2323
}
2424
baseName = 'RIP'
2525
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }

src/main/java/main/Rip2.java

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class Rip2 {
6464
/**
6565
* The application was installed
6666
*/
67-
private boolean appInstalled = false;
67+
private boolean appInstalled;
6868

6969
/**
7070
* Folder where the results will be exported
@@ -74,7 +74,7 @@ public class Rip2 {
7474
/**
7575
* Location of the APK file
7676
*/
77-
private String apkLocation = "androidApps/tesos.apk";
77+
private String apkLocation;
7878

7979
/**
8080
* Package name of the application
@@ -123,17 +123,18 @@ public class Rip2 {
123123

124124
private boolean rippingOutsideApp;
125125

126-
public Rip2() throws RipException {
126+
private Rip2(String apkPath, String outputFolder) throws RipException {
127127
pacName = "";
128128
isRunning = true;
129-
statesTable = new Hashtable<String, State>();
130-
states = new ArrayList<State>();
131-
transitions = new ArrayList<Transition>();
129+
statesTable = new Hashtable<>();
130+
states = new ArrayList<>();
131+
transitions = new ArrayList<>();
132132
waitingTime = 500;
133133
Date nowFolder = new Date();
134134
SimpleDateFormat dateFormat = new SimpleDateFormat("hhmmss");
135135
String time = dateFormat.format(nowFolder);
136-
folderName = "./generated/generated_" + time;
136+
// folderName = "./generated/generated_" + time;
137+
folderName ="./"+ outputFolder;
137138
File newFolder = new File(folderName);
138139
newFolder.mkdirs();
139140

@@ -143,14 +144,18 @@ public Rip2() throws RipException {
143144
} catch (IOException | RipException e) {
144145
e.printStackTrace();
145146
}
146-
147+
apkLocation = apkPath;
147148
// Installs the APK in the device
148149
appInstalled = installAPK(apkLocation);
149150

150151
if (!appInstalled) {
151152
throw new RipException("APK could not be installed");
152153
}
153154

155+
if(aapt==null) {
156+
throw new RipException("AAPT_LOCATION was not set");
157+
}
158+
154159
// Launches the applications' main activity
155160
try {
156161
packageName = ExternalProcess2.getPackageName(aapt, apkLocation);
@@ -254,9 +259,9 @@ private void explore(State previousState, Transition executedTransition) {
254259
boolean stateChanges = false;
255260

256261
// While no changes in in the state are detected
257-
while (stateChanges == false) {
262+
while (!stateChanges) {
258263
stateTransition = currentState.popTransition();
259-
transitionType = executeTransition(stateTransition);
264+
//transitionType = executeTransition(stateTransition);
260265
// Waits until the executed transition changes the application current state
261266
waitTime(waitingTime);
262267
// Checks if the application changes due to the executed transition
@@ -344,7 +349,7 @@ private State findStateInGraph(State pState) {
344349
return found;
345350
}
346351

347-
public boolean stateChanges() throws CrawlingOutsideAppException, IOException, RipException {
352+
private boolean stateChanges() throws CrawlingOutsideAppException, IOException, RipException {
348353
String rawXML = ExternalProcess2.getCurrentViewHierarchy();
349354
if (rawXML.equals(currentState.getRawXML())) {
350355
return false;
@@ -482,18 +487,24 @@ public void addDetectedErrorToCurrentHybridState(HybridError error) {
482487
}
483488

484489
public static void main(String[] args) {
485-
System.out.println("\n 2018, Universidad de los Andes\n The Software Design Lab\n");
486-
System.out.println("https://thesoftwaredesignlab.github.io/\n");
487-
String s = String.join("\n", "🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥", "🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥",
488-
"🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥", "🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥 ",
489-
"🔥🔥 🔥🔥 🔥🔥 🔥🔥 ", "🔥🔥 🔥🔥 🔥🔥 🔥🔥 ",
490-
"🔥🔥 🔥🔥 🔥🔥 🔥🔥 ", " ");
491-
492-
System.out.println(s);
493-
try {
494-
new Rip2();
495-
} catch (RipException e) {
496-
e.printStackTrace();
490+
491+
if(args.length<2) {
492+
System.err.println("Some arguments are missing, please provide apk location and outputfolder");
493+
} else {
494+
System.out.println("\n 2018, Universidad de los Andes\n The Software Design Lab\n");
495+
System.out.println("https://thesoftwaredesignlab.github.io/\n");
496+
String s = String.join("\n", "🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥", "🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥",
497+
"🔥🔥 🔥🔥 🔥🔥 🔥🔥 🔥🔥", "🔥🔥🔥🔥🔥🔥 🔥🔥 🔥🔥🔥🔥🔥🔥 ",
498+
"🔥🔥 🔥🔥 🔥🔥 🔥🔥 ", "🔥🔥 🔥🔥 🔥🔥 🔥🔥 ",
499+
"🔥🔥 🔥🔥 🔥🔥 🔥🔥 ", " ");
500+
501+
502+
System.out.println(s);
503+
try {
504+
new Rip2(args[0], args[1]);
505+
} catch (RipException e) {
506+
e.printStackTrace();
507+
}
497508
}
498509
}
499510

0 commit comments

Comments
 (0)