-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinalSurgicalMerger.java
More file actions
72 lines (63 loc) · 3.04 KB
/
Copy pathFinalSurgicalMerger.java
File metadata and controls
72 lines (63 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.nio.file.*;
public class FinalSurgicalMerger {
public static void main(String[] args) throws Exception {
File baseApk = new File("D:/Ideas/Antigravity/Notes/apks_extracted/base.apk");
File outputApk = new File("D:/Ideas/Antigravity/Notes/Notes_Standalone_Master.apk");
ZipInputStream zin = new ZipInputStream(new FileInputStream(baseApk));
ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(outputApk));
Set<String> replaced = new HashSet<>(Arrays.asList("classes.dex", "classes2.dex", "AndroidManifest.xml"));
ZipEntry entry = zin.getNextEntry();
while (entry != null) {
if (!replaced.contains(entry.getName())) {
zout.putNextEntry(new ZipEntry(entry.getName()));
byte[] buf = new byte[1024];
int len;
while ((len = zin.read(buf)) > 0) {
zout.write(buf, 0, len);
}
zout.closeEntry();
}
entry = zin.getNextEntry();
}
zin.close();
addFile(zout, "D:/Ideas/Antigravity/Notes/new_dex/classes.dex", "classes.dex");
addFile(zout, "D:/Ideas/Antigravity/Notes/new_dex/classes2.dex", "classes2.dex");
addFile(zout, "D:/Ideas/Antigravity/Notes/AndroidManifest.bin", "AndroidManifest.xml");
addSplitFiles(zout, "D:/Ideas/Antigravity/Notes/apks_extracted/split_config.arm64_v8a.apk", "lib/");
addSplitFiles(zout, "D:/Ideas/Antigravity/Notes/apks_extracted/split_config.xxhdpi.apk", "res/");
String[] langs = {"bn", "en", "gu", "hi", "kn", "mr", "ta", "te"};
for (String lang : langs) {
addSplitFiles(zout, "D:/Ideas/Antigravity/Notes/apks_extracted/split_config." + lang + ".apk", "res/");
}
zout.close();
System.out.println("Surgical Master Merge Complete.");
}
private static void addFile(ZipOutputStream zout, String srcPath, String entryName) throws IOException {
zout.putNextEntry(new ZipEntry(entryName));
zout.write(Files.readAllBytes(Paths.get(srcPath)));
zout.closeEntry();
}
private static void addSplitFiles(ZipOutputStream zout, String splitPath, String prefix) throws IOException {
try (ZipInputStream zin = new ZipInputStream(new FileInputStream(splitPath))) {
ZipEntry entry;
while ((entry = zin.getNextEntry()) != null) {
if (entry.getName().startsWith(prefix)) {
try {
zout.putNextEntry(new ZipEntry(entry.getName()));
byte[] buf = new byte[1024];
int len;
while ((len = zin.read(buf)) > 0) {
zout.write(buf, 0, len);
}
zout.closeEntry();
} catch (ZipException e) {
}
}
zin.closeEntry();
}
}
}
}