Skip to content

Commit eec2b65

Browse files
committed
Patch the update script to force use mkbootfs
Cpio command from busybox is somehow broken on boot mode when dealing with symlinks. Fortunately, anykernel still supports mkbootfs, we can easily switch to it.
1 parent 1889b4d commit eec2b65

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

app/src/main/assets/mkbootfs

11.8 KB
Binary file not shown.

app/src/main/java/xzr/hkf/Worker.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.io.InputStreamReader;
1313
import java.io.OutputStreamWriter;
1414

15+
import xzr.hkf.utils.AssetsUtil;
16+
1517
public class Worker extends MainActivity.fileWorker {
1618
Activity activity;
1719
String file_path;
@@ -67,6 +69,11 @@ public void run() {
6769
return;
6870
}
6971

72+
try {
73+
patch();
74+
} catch (IOException ignored) {
75+
}
76+
7077
try {
7178
flash(activity);
7279
} catch (IOException ioException) {
@@ -116,6 +123,13 @@ void getBinary() throws IOException {
116123
throw new IOException();
117124
}
118125

126+
void patch() throws IOException {
127+
final String mkbootfs_path = activity.getFilesDir().getAbsolutePath() + "/mkbootfs";
128+
AssetsUtil.exportFiles(activity, "mkbootfs", mkbootfs_path);
129+
130+
runWithNewProcessNoReturn(false, "sed -i '/$BB chmod -R 755 tools bin;/i cp -f " + mkbootfs_path + " $AKHOME/tools;' " + binary_path);
131+
}
132+
119133
void flash(Activity activity) throws IOException {
120134
Process process = new ProcessBuilder("su").redirectErrorStream(true).start();
121135
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(process.getOutputStream());
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package xzr.hkf.utils;
2+
3+
import android.content.Context;
4+
5+
import java.io.File;
6+
import java.io.FileOutputStream;
7+
import java.io.IOException;
8+
import java.io.InputStream;
9+
10+
public class AssetsUtil {
11+
public static void exportFiles(Context context, String src, String out) throws IOException {
12+
String[] fileNames = context.getAssets().list(src);
13+
if (fileNames.length > 0) {
14+
File file = new File(out);
15+
file.mkdirs();
16+
for (String fileName : fileNames) {
17+
exportFiles(context, src + "/" + fileName, out + "/" + fileName);
18+
}
19+
} else {
20+
InputStream is = context.getAssets().open(src);
21+
FileOutputStream fos = new FileOutputStream(new File(out));
22+
byte[] buffer = new byte[1024];
23+
int byteCount = 0;
24+
while ((byteCount = is.read(buffer)) != -1) {
25+
fos.write(buffer, 0, byteCount);
26+
}
27+
fos.flush();
28+
is.close();
29+
fos.close();
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)