diff --git a/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadModuleService.java b/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadModuleService.java index a3d5e0987..ceb3ea494 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadModuleService.java +++ b/app/src/main/java/com/topjohnwu/magisk/model/download/DownloadModuleService.java @@ -25,7 +25,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; @@ -95,7 +94,7 @@ public class DownloadModuleService extends Service { .setDownloadProgressListener(progress) .execForInputStream().getResult(); OutputStream out = new BufferedOutputStream(new FileOutputStream(output)); - processZip(in, out, repo.isNewInstaller()); + processZip(in, out); Intent intent = new Intent(this, ClassMap.get(FlashActivity.class)); intent.setData(Uri.fromFile(output)) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) @@ -120,25 +119,23 @@ public class DownloadModuleService extends Service { removeNotification(progress); } - private void processZip(InputStream in, OutputStream out, boolean inject) + private void processZip(InputStream in, OutputStream out) throws IOException { try (ZipInputStream zin = new ZipInputStream(in); ZipOutputStream zout = new ZipOutputStream(out)) { - if (inject) { - // Inject latest module-installer.sh as update-binary - zout.putNextEntry(new ZipEntry("META-INF/")); - zout.putNextEntry(new ZipEntry("META-INF/com/")); - zout.putNextEntry(new ZipEntry("META-INF/com/google/")); - zout.putNextEntry(new ZipEntry("META-INF/com/google/android/")); - zout.putNextEntry(new ZipEntry("META-INF/com/google/android/update-binary")); - try (InputStream update_bin = Networking.get(Const.Url.MODULE_INSTALLER) - .execForInputStream().getResult()) { - ShellUtils.pump(update_bin, zout); - } - zout.putNextEntry(new ZipEntry("META-INF/com/google/android/updater-script")); - zout.write("#MAGISK\n".getBytes(StandardCharsets.UTF_8)); + // Inject latest module-installer.sh as update-binary + zout.putNextEntry(new ZipEntry("META-INF/")); + zout.putNextEntry(new ZipEntry("META-INF/com/")); + zout.putNextEntry(new ZipEntry("META-INF/com/google/")); + zout.putNextEntry(new ZipEntry("META-INF/com/google/android/")); + zout.putNextEntry(new ZipEntry("META-INF/com/google/android/update-binary")); + try (InputStream update_bin = Networking.get(Const.Url.MODULE_INSTALLER) + .execForInputStream().getResult()) { + ShellUtils.pump(update_bin, zout); } + zout.putNextEntry(new ZipEntry("META-INF/com/google/android/updater-script")); + zout.write("#MAGISK\n".getBytes("UTF-8")); int off = -1; ZipEntry entry; @@ -148,7 +145,7 @@ public class DownloadModuleService extends Service { String path = entry.getName().substring(off); if (path.isEmpty()) continue; - if (inject && path.startsWith("META-INF")) + if (path.startsWith("META-INF")) continue; zout.putNextEntry(new ZipEntry(path)); if (!entry.isDirectory()) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/entity/Repo.java b/app/src/main/java/com/topjohnwu/magisk/model/entity/Repo.java index 43f85f12e..4932ae1ea 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/entity/Repo.java +++ b/app/src/main/java/com/topjohnwu/magisk/model/entity/Repo.java @@ -7,8 +7,6 @@ import android.os.Parcelable; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.utils.Utils; -import com.topjohnwu.net.Networking; -import com.topjohnwu.net.Request; import java.text.DateFormat; import java.util.Date; @@ -91,18 +89,6 @@ public class Repo extends BaseModule { return String.format(Const.Url.FILE_URL, getId(), file); } - public boolean isNewInstaller() { - try (Request install = Networking.get(getFileUrl("install.sh"))) { - if (install.connect().isSuccess()) { - // Double check whether config.sh exists - try (Request config = Networking.get(getFileUrl("config.sh"))) { - return !config.connect().isSuccess(); - } - } - return false; - } - } - public String getLastUpdateString() { return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(mLastUpdate); }