Skip to content

Commit

Permalink
0.0.3, add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Zaitsev committed Sep 23, 2016
1 parent c02dbb7 commit 9475430
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
Binary file removed apk_dependency_graph_0.0.2.jar
Binary file not shown.
Binary file added apk_dependency_graph_0.0.3.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions code/CodeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
public class CodeUtils {

public static boolean isClassR(String className) {
return className.equals("R") || className.startsWith("R$");
return className != null && className.equals("R") || className.startsWith("R$");
}

public static boolean isClassGenerated(String className) {
return className.contains("$$");
return className != null && className.contains("$$");
}

public static boolean isClassInner(String className) {
return className.contains("$") && !isClassAnonymous(className) && !isClassGenerated(className);
return className != null && className.contains("$") && !isClassAnonymous(className) && !isClassGenerated(className);
}

public static String getOuterClass(String className) {
return className.substring(0, className.lastIndexOf("$"));
}

public static boolean isClassAnonymous(String className) {
return className.contains("$")
return className != null && className.contains("$")
&& StringUtils.isNumber(className.substring(className.lastIndexOf("$") + 1, className.length()));
}

Expand Down
23 changes: 13 additions & 10 deletions code/SmaliAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,21 @@ private void processSmaliFile(File file) {
Set<String> dependencyNames = new HashSet<>();

for (String line; (line = br.readLine()) != null;) {
classNames.clear();

parseAndAddClassNames(classNames, line);

// filtering
for (String fullClassName : classNames) {
if (fullClassName != null && isFilterOk(fullClassName)) {
String simpleClassName = getClassSimpleName(fullClassName);
if (isClassOk(simpleClassName, fileName)) {
dependencyNames.add(simpleClassName);
try {
classNames.clear();

parseAndAddClassNames(classNames, line);

// filtering
for (String fullClassName : classNames) {
if (fullClassName != null && isFilterOk(fullClassName)) {
String simpleClassName = getClassSimpleName(fullClassName);
if (isClassOk(simpleClassName, fileName)) {
dependencyNames.add(simpleClassName);
}
}
}
} catch (Exception e) {
}
}

Expand Down
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Set outPath=%~dp0\%Name:~0,-4%
Set jsonPath=%~dp0\analyzed.js

java -jar %~dp0\apktool_2.2.0.jar d %1 -o %outPath% -f
java -jar %~dp0\apk_dependency_graph_0.0.2.jar -i %outPath% -o %jsonPath% -f %2
java -jar %~dp0\apk_dependency_graph_0.0.3.jar -i %outPath% -o %jsonPath% -f %2
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ outPath=${dir}"/"${xpref}
jsonPath=${dir}"/analyzed.js"

eval "java -jar ${dir}'/apktool_2.2.0.jar' d ${fileName} -o ${outPath} -f"
eval "java -jar ${dir}'/apk_dependency_graph_0.0.2.jar' -i ${outPath} -o ${jsonPath} -f $2"
eval "java -jar ${dir}'/apk_dependency_graph_0.0.3.jar' -i ${outPath} -o ${jsonPath} -f $2"

0 comments on commit 9475430

Please sign in to comment.