MCPcopy Create free account
hub / github.com/KuhakuPixel/AceTheGame / Patch

Method Patch

Modder/modder/src/main/java/modder/App.java:128–169  ·  view source on GitHub ↗
(

			@Parameters(paramLabel = "ApkFolderPath", description = "Path to directory containing apks") String apkDirStr,

			@Parameters(paramLabel = "attachMemScanner", description = "attach a memory scanner to apk")

			boolean attachMemScanner

	)

Source from the content-addressed store, hash-verified

126 }
127
128 @Command(name = "Patch", description = "recompile apks")
129 void Patch(
130
131 @Parameters(paramLabel = "ApkFolderPath", description = "Path to directory containing apks") String apkDirStr,
132
133 @Parameters(paramLabel = "attachMemScanner", description = "attach a memory scanner to apk")
134
135 boolean attachMemScanner
136
137 ) throws IOException {
138
139 // check if the directory exist
140 File apkSrcDir = new File(apkDirStr);
141 Assert.AssertExistAndIsDirectory(apkSrcDir);
142 // copy apk folder so we dont write to the original one
143 File apkDir = new File(apkSrcDir.getAbsolutePath() + ".patched");
144 FileUtils.copyDirectory(apkSrcDir, apkDir);
145
146 // get the base apk for patching
147 File baseApkFile = new File(apkDir.getAbsolutePath(), Patcher.BASE_APK_FILE_NAME);
148 Assert.AssertExistAndIsFile(baseApkFile);
149 // add patch
150 Patcher patcher = new Patcher(baseApkFile.getAbsolutePath());
151 if (attachMemScanner)
152 patcher.AddMemScanner();
153
154 // export
155 // String patchedApkPath = baseApkFile.getAbsolutePath() + "-patched.apk";
156 String patchedApkPath = baseApkFile.getAbsolutePath();
157 patcher.Export(patchedApkPath);
158 System.out.printf("exported apk to %s\n", patchedApkPath);
159 // sign all the apk in the directory
160 File[] files = apkDir.listFiles();
161 for (File f : files) {
162 if (f.isFile()) {
163 String[] args = new String[] { "--apks", f.getAbsolutePath(), "--allowResign", "--overwrite" };
164 SignTool.main(args);
165 }
166
167 }
168
169 }
170
171 /*
172 * Download apk from device specified by [package_name]

Callers

nothing calls this directly

Calls 5

AssertExistAndIsFileMethod · 0.95
AddMemScannerMethod · 0.95
ExportMethod · 0.95
mainMethod · 0.80

Tested by

no test coverage detected