Add RawDexIO.writeRawDexFile(DexDataStore dataStore, ...)

This commit is contained in:
Lanchon 2017-09-25 00:28:12 -03:00
parent 44fc0cf19e
commit 429f4ac79b
2 changed files with 12 additions and 5 deletions

View File

@ -29,6 +29,7 @@ import com.google.common.collect.PeekingIterator;
import org.jf.dexlib2.Opcodes; import org.jf.dexlib2.Opcodes;
import org.jf.dexlib2.iface.ClassDef; import org.jf.dexlib2.iface.ClassDef;
import org.jf.dexlib2.iface.DexFile; import org.jf.dexlib2.iface.DexFile;
import org.jf.dexlib2.writer.io.DexDataStore;
import org.jf.dexlib2.writer.io.FileDataStore; import org.jf.dexlib2.writer.io.FileDataStore;
import org.jf.dexlib2.writer.pool.DexPool; import org.jf.dexlib2.writer.pool.DexPool;
@ -44,8 +45,8 @@ public class DexIO {
// Single-Threaded Write // Single-Threaded Write
static void writeRawDexSingleThread(File file, DexFile dexFile, int maxDexPoolSize, DexIO.Logger logger) static void writeRawDexSingleThread(DexDataStore dataStore, DexFile dexFile, int maxDexPoolSize,
throws IOException { DexIO.Logger logger, File file) throws IOException {
Set<? extends ClassDef> classes = dexFile.getClasses(); Set<? extends ClassDef> classes = dexFile.getClasses();
Iterator<? extends ClassDef> classIterator = classes.iterator(); Iterator<? extends ClassDef> classIterator = classes.iterator();
DexPool dexPool = new DexPool(dexFile.getOpcodes()); DexPool dexPool = new DexPool(dexFile.getOpcodes());
@ -60,7 +61,7 @@ public class DexIO {
classCount++; classCount++;
} }
if (logger != null) logger.log(file, SingletonDexContainer.UNDEFINED_ENTRY_NAME, classCount); if (logger != null) logger.log(file, SingletonDexContainer.UNDEFINED_ENTRY_NAME, classCount);
dexPool.writeTo(new FileDataStore(file)); dexPool.writeTo(dataStore);
} }
static void writeMultiDexDirectorySingleThread(boolean multiDex, File directory, DexFileNameIterator nameIterator, static void writeMultiDexDirectorySingleThread(boolean multiDex, File directory, DexFileNameIterator nameIterator,

View File

@ -21,6 +21,8 @@ import org.jf.dexlib2.dexbacked.DexBackedDexFile;
import org.jf.dexlib2.dexbacked.raw.HeaderItem; import org.jf.dexlib2.dexbacked.raw.HeaderItem;
import org.jf.dexlib2.iface.DexFile; import org.jf.dexlib2.iface.DexFile;
import org.jf.dexlib2.util.DexUtil; import org.jf.dexlib2.util.DexUtil;
import org.jf.dexlib2.writer.io.DexDataStore;
import org.jf.dexlib2.writer.io.FileDataStore;
public class RawDexIO { public class RawDexIO {
@ -67,11 +69,15 @@ public class RawDexIO {
public static void writeRawDexFile(File file, DexFile dexFile, int maxDexPoolSize, DexIO.Logger logger) public static void writeRawDexFile(File file, DexFile dexFile, int maxDexPoolSize, DexIO.Logger logger)
throws IOException { throws IOException {
DexIO.writeRawDexSingleThread(file, dexFile, maxDexPoolSize, logger); DexIO.writeRawDexSingleThread(new FileDataStore(file), dexFile, maxDexPoolSize, logger, file);
} }
public static void writeRawDexFile(File file, DexFile dexFile, int maxDexPoolSize) throws IOException { public static void writeRawDexFile(File file, DexFile dexFile, int maxDexPoolSize) throws IOException {
DexIO.writeRawDexSingleThread(file, dexFile, maxDexPoolSize, null); DexIO.writeRawDexSingleThread(new FileDataStore(file), dexFile, maxDexPoolSize, null, null);
}
public static void writeRawDexFile(DexDataStore dataStore, DexFile dexFile, int maxDexPoolSize) throws IOException {
DexIO.writeRawDexSingleThread(dataStore, dexFile, maxDexPoolSize, null, null);
} }
} }