Search in sources :

Example 1 with ContentReader

use of com.google.classyshark.silverghost.contentreader.ContentReader in project android-classyshark by google.

the class SilverGhost method readContents.

//                     1. READ CONTENTS
public void readContents() {
    contentReader = new ContentReader(getBinaryArchive());
    long start = System.currentTimeMillis();
    contentReader.load();
    reducer = new Reducer(contentReader.getAllClassNames());
    System.out.println("Archive Reading " + (System.currentTimeMillis() - start) + " ms ");
    if (binaryArchive.getName().endsWith(".apk")) {
        Translator translator = TranslatorFactory.createTranslator("AndroidManifest.xml", binaryArchive);
        translator.apply();
        manifestStr = translator.toString();
    }
    fullArchiveReader.readAsyncArchive(binaryArchive);
}
Also used : Translator(com.google.classyshark.silverghost.translator.Translator) ContentReader(com.google.classyshark.silverghost.contentreader.ContentReader) Reducer(com.google.classyshark.gui.panel.reducer.Reducer)

Example 2 with ContentReader

use of com.google.classyshark.silverghost.contentreader.ContentReader in project android-classyshark by google.

the class SilverGhostFacade method isMultiDex.

/**
     * returns true if the apk is multidex
     *
     * @param archiveFile
     * @return
     */
public static boolean isMultiDex(File archiveFile) {
    ContentReader contentReader = new ContentReader(archiveFile);
    contentReader.load();
    List<String> allClassNames = contentReader.getAllClassNames();
    int numDexes = 0;
    for (String classEntry : allClassNames) {
        if (classEntry.endsWith(".dex")) {
            numDexes++;
            // 2 dexes or more + optimization
            if (numDexes == 2) {
                return true;
            }
        }
    }
    return false;
}
Also used : ContentReader(com.google.classyshark.silverghost.contentreader.ContentReader)

Example 3 with ContentReader

use of com.google.classyshark.silverghost.contentreader.ContentReader in project android-classyshark by google.

the class SilverGhostFacade method isCustomMultiDex.

/**
     * returns true if the apk is custom dex loading multidex
     *
     * @param archiveFile
     * @return
     */
public static boolean isCustomMultiDex(File archiveFile) {
    if (!isMultiDex(archiveFile)) {
        return false;
    }
    ContentReader contentReader = new ContentReader(archiveFile);
    contentReader.load();
    List<String> allClassNames = contentReader.getAllClassNames();
    List<String> allDexNames = new LinkedList<>();
    for (String classEntry : allClassNames) {
        if (classEntry.endsWith(".dex")) {
            allDexNames.add(classEntry);
        }
    }
    if (allClassNames.contains("classes1.dex")) {
        return true;
    }
    for (String classEntry : allDexNames) {
        if (!classEntry.startsWith("classes")) {
            return true;
        }
    }
    return false;
}
Also used : ContentReader(com.google.classyshark.silverghost.contentreader.ContentReader) LinkedList(java.util.LinkedList)

Example 4 with ContentReader

use of com.google.classyshark.silverghost.contentreader.ContentReader in project android-classyshark by google.

the class Exporter method main.

public static void main(String[] args) throws Exception {
    String allAndroid = System.getProperty("user.home") + "/Desktop/Scenarios/2 Samples/android.jar";
    ContentReader loader = new ContentReader(new File(allAndroid));
    loader.load();
    writeClassNames(loader.getAllClassNames());
}
Also used : ContentReader(com.google.classyshark.silverghost.contentreader.ContentReader) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 5 with ContentReader

use of com.google.classyshark.silverghost.contentreader.ContentReader in project android-classyshark by google.

the class SilverGhostFacade method getAllClassNames.

public static List<String> getAllClassNames(File archiveFile) {
    ContentReader loader = new ContentReader(archiveFile);
    loader.load();
    return loader.getAllClassNames();
}
Also used : ContentReader(com.google.classyshark.silverghost.contentreader.ContentReader)

Aggregations

ContentReader (com.google.classyshark.silverghost.contentreader.ContentReader)6 Reducer (com.google.classyshark.gui.panel.reducer.Reducer)2 File (java.io.File)2 Translator (com.google.classyshark.silverghost.translator.Translator)1 RandomAccessFile (java.io.RandomAccessFile)1 LinkedList (java.util.LinkedList)1 JFrame (javax.swing.JFrame)1 JScrollPane (javax.swing.JScrollPane)1