From 09bdbc1224412301f9f0f98cbeaada381ba9ebd3 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 28 Jan 2017 01:25:51 +0800 Subject: [PATCH] Revert "Read only the first line instead of loading the whole file" This reverts commit a5b573eaaa5b5e799dcd12d929a13d8d46a226a0. The file shall always have one single line, no need to create a new method --- .../main/java/com/topjohnwu/magisk/utils/Async.java | 5 +++-- .../main/java/com/topjohnwu/magisk/utils/Utils.java | 11 ----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java index f408e3dff..5989c324e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java @@ -218,8 +218,9 @@ public class Async { protected boolean unzipAndCheck() { ZipUtils.unzip(mCachedFile, mCachedFile.getParentFile(), "META-INF/com/google/android"); - String line = Utils.readFirstLine(mCachedFile.getParent() + "/META-INF/com/google/android/updater-script"); - return line != null && line.contains("#MAGISK"); + List ret; + ret = Utils.readFile(mCachedFile.getParent() + "/META-INF/com/google/android/updater-script"); + return Utils.isValidShellResponse(ret) && ret.get(0).contains("#MAGISK"); } @Override diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index 08aeddd1a..36a90e652 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -75,17 +75,6 @@ public class Utils { return ret; } - public static String readFirstLine(String path) { - List ret; - String command = "head -1 " + path; - if (Shell.rootAccess()) { - ret = Shell.su(command); - } else { - ret = Shell.sh(command); - } - return isValidShellResponse(ret) ? ret.get(0) : null; - } - public static void dlAndReceive(Context context, DownloadReceiver receiver, String link, String filename) { if (isDownloading) { return;