diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/RestoreStockBoot.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/RestoreStockBoot.java index fd6717c0d..6854e28c4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/RestoreStockBoot.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/RestoreStockBoot.java @@ -19,10 +19,18 @@ public class RestoreStockBoot extends ParallelTask { @Override protected Boolean doInBackground(Void... voids) { - List ret = Shell.su("cat /init.magisk.rc | grep STOCKSHA1"); - if (!Utils.isValidShellResponse(ret)) - return false; - String stock_boot = "/data/stock_boot_" + ret.get(0).substring(ret.get(0).indexOf('=') + 1) + ".img.gz"; + String sha1; + List ret = Utils.readFile("/.backup/.sha1"); + if (!Utils.isValidShellResponse(ret)) { + ret = Shell.su("cat /init.magisk.rc | grep STOCKSHA1"); + if (!Utils.isValidShellResponse(ret)) + return false; + sha1 = ret.get(0).substring(ret.get(0).indexOf('=') + 1); + } else { + sha1 = ret.get(0); + } + + String stock_boot = "/data/stock_boot_" + sha1 + ".img.gz"; if (!Utils.itemExist(stock_boot)) return false; Shell.su_raw("flash_boot_image " + stock_boot + " " + mBoot);