Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Ensure auto restart works
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Jan 12, 2021
1 parent 6a0262a commit 600ac35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions riru/src/main/java/riru/Daemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ private void startWait(boolean allowRestart, boolean isFirst) {

try {
binder.linkToDeath(() -> {
DaemonUtils.deleteDevFolder();

Log.i(TAG, "Zygote is probably dead, restart rirud socket...");
DaemonUtils.startSocket(DaemonUtils.findNativeDaemonPid());

Expand Down
15 changes: 14 additions & 1 deletion riru/src/main/java/riru/DaemonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static IBinder waitForSystemService(String name) {
} while (true);
}

public static boolean isRiruLoaded() {
public static String getRiruRandom() {
String devRandom = null;
try (BufferedReader br = new BufferedReader(new FileReader(new File("/data/adb/riru/dev_random")))) {
char[] buf = new char[4096];
Expand All @@ -72,14 +72,27 @@ public static boolean isRiruLoaded() {
} catch (IOException e) {
Log.w(Daemon.TAG, "Can't read dev_random.", e);
}
return devRandom;
}

public static boolean isRiruLoaded() {
String devRandom = getRiruRandom();
if (devRandom == null) {
return false;
}

return new File("/dev/riru_" + devRandom).exists();
}

public static boolean deleteDevFolder() {
String devRandom = getRiruRandom();
if (devRandom == null) {
return false;
}

return new File("/dev/riru_" + devRandom).delete();
}

public static int findNativeDaemonPid() {
File proc = new File("/proc");

Expand Down

0 comments on commit 600ac35

Please sign in to comment.