mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-20 16:57:34 +01:00
+Androlib.publicizeResources()
This commit is contained in:
parent
dc190d9210
commit
329d9b4b3f
@ -20,6 +20,8 @@ package brut.androlib;
|
||||
import brut.androlib.java.AndrolibJava;
|
||||
import brut.androlib.res.AndrolibResources;
|
||||
import brut.androlib.res.data.ResTable;
|
||||
import brut.androlib.res.decoder.ARSCDecoder;
|
||||
import brut.androlib.res.decoder.ARSCDecoder.FlagsOffset;
|
||||
import brut.androlib.res.util.ExtFile;
|
||||
import brut.androlib.src.SmaliBuilder;
|
||||
import brut.androlib.src.SmaliDecoder;
|
||||
@ -28,6 +30,9 @@ import brut.directory.*;
|
||||
import brut.util.BrutIO;
|
||||
import brut.util.OS;
|
||||
import java.io.*;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel.MapMode;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@ -305,6 +310,28 @@ public class Androlib {
|
||||
new File(appDir, APK_DIRNAME), assetDir, false, true);
|
||||
}
|
||||
|
||||
public void publicizeResources(File arscFile) throws AndrolibException {
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(arscFile);
|
||||
List<FlagsOffset> offsets = ARSCDecoder.findFlagsOffsets(in);
|
||||
in.close();
|
||||
|
||||
RandomAccessFile raf = new RandomAccessFile(arscFile, "rw");
|
||||
MappedByteBuffer buf = raf.getChannel().map(MapMode.READ_WRITE, 0, arscFile.length());
|
||||
for (FlagsOffset flags : offsets) {
|
||||
int offset = flags.offset + 3;
|
||||
int end = offset + 4 * flags.count;
|
||||
while(offset < end) {
|
||||
buf.put(offset, (byte) (buf.get(offset) | (byte) 0x40));
|
||||
offset += 4;
|
||||
}
|
||||
}
|
||||
raf.close();
|
||||
} catch (IOException ex) {
|
||||
throw new AndrolibException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isModified(File working, File stored) {
|
||||
if (! stored.exists()) {
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user