Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Synthetic accessors #120

Merged
merged 5 commits into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ClassySharkWS/src/com/google/classyshark/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
*/
public class Version {

public static final int MAJOR = 6;
public static final int MINOR = 7;
public static final int MAJOR = 7;
public static final int MINOR = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@

import com.google.classyshark.silverghost.contentreader.BinaryContentReader;
import com.google.classyshark.silverghost.contentreader.ContentReader;
import com.google.classyshark.silverghost.contentreader.dex.DexReader;
import com.google.classyshark.silverghost.translator.xml.XmlDecompressor;

import com.google.classyshark.silverghost.io.SherlockHash;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import static com.google.classyshark.silverghost.translator.java.dex.Multidex.readClassNamesFromMultidex;

public class ApkReader implements BinaryContentReader {

Expand All @@ -44,7 +38,7 @@ public ApkReader(File binaryArchive) {
public void read() {
readClassNamesFromMultidex(binaryArchive, allClassNames, components);

// TODO add check for manifest
// TODO add isPrivate for manifest
// allClassNames.add(6, "AndroidManifest.xml");
}

Expand All @@ -58,95 +52,4 @@ public List<ContentReader.Component> getComponents() {
// TODO add manifest here
return components;
}

private static void readClassNamesFromMultidex(File binaryArchiveFile,
List<String> classNames,
List<ContentReader.Component> components) {
ZipInputStream zipInputStream;
try {
zipInputStream = new ZipInputStream(new FileInputStream(
binaryArchiveFile));

ZipEntry zipEntry;

int dexIndex = 0;
while (true) {
zipEntry = zipInputStream.getNextEntry();

if (zipEntry == null) {
break;
}

if (zipEntry.getName().endsWith(".xml")) {
classNames.add(zipEntry.getName());
}

if (zipEntry.getName().endsWith(".dex")) {
String fName = "classes";
if(dexIndex > 0) {
fName = fName + dexIndex;
}
String ext = "dex";

File file = SherlockHash.INSTANCE.getFileFromZipStream(binaryArchiveFile,
zipInputStream, fName, ext);

List<String> classesAtDex =
DexReader.readClassNamesFromDex(file);

classNames.add(fName + ".dex");
classNames.addAll(classesAtDex);
dexIndex++;
}
if (zipEntry.getName().startsWith("lib")) {
components.add(
new ContentReader.Component(zipEntry.getName(),
ContentReader.ARCHIVE_COMPONENT.NATIVE_LIBRARY));
}

// Dynamic dex loading
if (zipEntry.getName().endsWith("jar") || zipEntry.getName().endsWith("zip")) {
String fName = "inner_zip";
String ext = "zip";

File innerZip = SherlockHash.INSTANCE.getFileFromZipStream(binaryArchiveFile,
zipInputStream, fName, ext);

// so far we have a zip file
ZipInputStream fromInnerZip = new ZipInputStream(new FileInputStream(
innerZip));

ZipEntry innerZipEntry;

while (true) {
innerZipEntry = fromInnerZip.getNextEntry();

if (innerZipEntry == null) {
break;
}

if (innerZipEntry.getName().endsWith(".dex")) {
fName = "inner_zip_classes" + dexIndex;
ext = "dex";
File tempDexFile =
SherlockHash.INSTANCE.getFileFromZipStream(binaryArchiveFile,
fromInnerZip, fName, ext);

List<String> classesAtDex =
DexReader.readClassNamesFromDex(tempDexFile);

String name = zipEntry.getName() + "###" + innerZipEntry.getName();

classNames.add(name);
classNames.addAll(classesAtDex);
}
}
}
}
zipInputStream.close();

} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading