mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
No more old module exists
This commit is contained in:
parent
fb40e96917
commit
0893ac3141
@ -25,7 +25,6 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
@ -95,7 +94,7 @@ public class DownloadModuleService extends Service {
|
|||||||
.setDownloadProgressListener(progress)
|
.setDownloadProgressListener(progress)
|
||||||
.execForInputStream().getResult();
|
.execForInputStream().getResult();
|
||||||
OutputStream out = new BufferedOutputStream(new FileOutputStream(output));
|
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 intent = new Intent(this, ClassMap.get(FlashActivity.class));
|
||||||
intent.setData(Uri.fromFile(output))
|
intent.setData(Uri.fromFile(output))
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
@ -120,12 +119,11 @@ public class DownloadModuleService extends Service {
|
|||||||
removeNotification(progress);
|
removeNotification(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processZip(InputStream in, OutputStream out, boolean inject)
|
private void processZip(InputStream in, OutputStream out)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try (ZipInputStream zin = new ZipInputStream(in);
|
try (ZipInputStream zin = new ZipInputStream(in);
|
||||||
ZipOutputStream zout = new ZipOutputStream(out)) {
|
ZipOutputStream zout = new ZipOutputStream(out)) {
|
||||||
|
|
||||||
if (inject) {
|
|
||||||
// Inject latest module-installer.sh as update-binary
|
// Inject latest module-installer.sh as update-binary
|
||||||
zout.putNextEntry(new ZipEntry("META-INF/"));
|
zout.putNextEntry(new ZipEntry("META-INF/"));
|
||||||
zout.putNextEntry(new ZipEntry("META-INF/com/"));
|
zout.putNextEntry(new ZipEntry("META-INF/com/"));
|
||||||
@ -137,8 +135,7 @@ public class DownloadModuleService extends Service {
|
|||||||
ShellUtils.pump(update_bin, zout);
|
ShellUtils.pump(update_bin, zout);
|
||||||
}
|
}
|
||||||
zout.putNextEntry(new ZipEntry("META-INF/com/google/android/updater-script"));
|
zout.putNextEntry(new ZipEntry("META-INF/com/google/android/updater-script"));
|
||||||
zout.write("#MAGISK\n".getBytes(StandardCharsets.UTF_8));
|
zout.write("#MAGISK\n".getBytes("UTF-8"));
|
||||||
}
|
|
||||||
|
|
||||||
int off = -1;
|
int off = -1;
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
@ -148,7 +145,7 @@ public class DownloadModuleService extends Service {
|
|||||||
String path = entry.getName().substring(off);
|
String path = entry.getName().substring(off);
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (inject && path.startsWith("META-INF"))
|
if (path.startsWith("META-INF"))
|
||||||
continue;
|
continue;
|
||||||
zout.putNextEntry(new ZipEntry(path));
|
zout.putNextEntry(new ZipEntry(path));
|
||||||
if (!entry.isDirectory())
|
if (!entry.isDirectory())
|
||||||
|
@ -7,8 +7,6 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.net.Networking;
|
|
||||||
import com.topjohnwu.net.Request;
|
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -91,18 +89,6 @@ public class Repo extends BaseModule {
|
|||||||
return String.format(Const.Url.FILE_URL, getId(), file);
|
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() {
|
public String getLastUpdateString() {
|
||||||
return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(mLastUpdate);
|
return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(mLastUpdate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user