Skip to content

Commit

Permalink
Onboarding: Write logs if module installation failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Sep 26, 2023
1 parent 69f8be9 commit aadbb4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ protected Integer doInBackground(Void... voids) {
hasErroredOut = ModuleUtil.flashModule(ModuleUtil.createModule(Resources.TEMP_MODULE_DIR, Resources.TEMP_DIR + "/Iconify.zip"));
} catch (Exception e) {
hasErroredOut = true;
writeLog(TAG, "Error creating module zip", e);
e.printStackTrace();
writeLog(TAG, "Failed to create/flash module zip", e);
Log.e(TAG, "Failed to create/flash module zip\n" + e);
}
}

Expand Down
27 changes: 19 additions & 8 deletions app/src/main/java/com/drdisagree/iconify/utils/ModuleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ static void installModule() {
Log.i(TAG, "Magisk module successfully created.");
}

public static boolean flashModule(String modulePath) {
if (RootUtil.isMagiskInstalled()) {
return !Shell.cmd("magisk --install-module " + modulePath).exec().isSuccess();
} else {
return !Shell.cmd("/data/adb/ksud module install " + modulePath).exec().isSuccess();
}
}

private static void writePostExec() {
StringBuilder post_exec = new StringBuilder();
boolean primaryColorEnabled = false;
Expand Down Expand Up @@ -157,4 +149,23 @@ public static String createModule(String sourceFolder, String destinationFilePat
return zipFile.getFile().getAbsolutePath();
}
}

public static boolean flashModule(String modulePath) throws Exception {
Shell.Result result;

if (RootUtil.isMagiskInstalled()) {
result = Shell.cmd("magisk --install-module " + modulePath).exec();
} else {
result = Shell.cmd("/data/adb/ksud module install " + modulePath).exec();
}

if (result.isSuccess()) {
Log.i(TAG, "Successfully flashed module");
} else {
Log.e(TAG, "Failed to flash module");
throw new Exception(String.join("\n", result.getOut()));
}

return !result.isSuccess();
}
}

0 comments on commit aadbb4d

Please sign in to comment.