mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 07:20:47 -05:00
Use internal library for networking
This commit is contained in:
@@ -5,8 +5,6 @@ import com.topjohnwu.utils.SignBoot;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
public class BootSigner {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.topjohnwu.magisk.utils;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.androidnetworking.AndroidNetworking;
|
||||
import com.androidnetworking.error.ANError;
|
||||
import com.androidnetworking.interfaces.DownloadListener;
|
||||
import com.topjohnwu.magisk.BuildConfig;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.asyncs.PatchAPK;
|
||||
import com.topjohnwu.magisk.components.ProgressNotification;
|
||||
import com.topjohnwu.net.Networking;
|
||||
import com.topjohnwu.net.ResponseListener;
|
||||
import com.topjohnwu.superuser.ShellUtils;
|
||||
import com.topjohnwu.utils.JarMap;
|
||||
import com.topjohnwu.utils.SignAPK;
|
||||
@@ -31,42 +30,35 @@ public class DlInstallManager {
|
||||
dlInstall(name, new RestoreManager());
|
||||
}
|
||||
|
||||
public static void dlInstall(String name, ManagerDownloadListener listener) {
|
||||
private static void dlInstall(String name, ManagerDownloadListener listener) {
|
||||
MagiskManager mm = Data.MM();
|
||||
File apk = new File(mm.getFilesDir(), "manager.apk");
|
||||
ProgressNotification progress = new ProgressNotification(name);
|
||||
listener.setInstances(apk, progress);
|
||||
AndroidNetworking
|
||||
.download(Data.managerLink, apk.getParent(), apk.getName())
|
||||
listener.setProgressNotification(progress);
|
||||
Networking.get(Data.managerLink)
|
||||
.setExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
|
||||
.build()
|
||||
.setDownloadProgressListener(progress)
|
||||
.startDownload(listener);
|
||||
.setErrorHandler((conn, e) -> progress.dlFail())
|
||||
.getAsFile(listener, apk);
|
||||
}
|
||||
|
||||
public abstract static class ManagerDownloadListener implements DownloadListener {
|
||||
private File apk;
|
||||
abstract static class ManagerDownloadListener implements ResponseListener<File> {
|
||||
|
||||
private ProgressNotification progress;
|
||||
|
||||
private void setInstances(File apk, ProgressNotification progress) {
|
||||
this.apk = apk;
|
||||
private void setProgressNotification(ProgressNotification progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public abstract void onDownloadComplete(File apk, ProgressNotification progress);
|
||||
|
||||
@Override
|
||||
public final void onDownloadComplete() {
|
||||
public void onResponse(File apk) {
|
||||
onDownloadComplete(apk, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ANError anError) {
|
||||
progress.dlFail();
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatchPackageName extends ManagerDownloadListener {
|
||||
static class PatchPackageName extends ManagerDownloadListener {
|
||||
|
||||
@Override
|
||||
public void onDownloadComplete(File apk, ProgressNotification progress) {
|
||||
@@ -92,7 +84,7 @@ public class DlInstallManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static class RestoreManager extends ManagerDownloadListener {
|
||||
static class RestoreManager extends ManagerDownloadListener {
|
||||
|
||||
@Override
|
||||
public void onDownloadComplete(File apk, ProgressNotification progress) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import android.os.AsyncTask;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.androidnetworking.AndroidNetworking;
|
||||
import com.topjohnwu.magisk.Const;
|
||||
import com.topjohnwu.magisk.Data;
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
@@ -24,6 +23,7 @@ import com.topjohnwu.magisk.R;
|
||||
import com.topjohnwu.magisk.container.Module;
|
||||
import com.topjohnwu.magisk.container.ValueSortedMap;
|
||||
import com.topjohnwu.magisk.services.UpdateCheckService;
|
||||
import com.topjohnwu.net.Networking;
|
||||
import com.topjohnwu.superuser.Shell;
|
||||
import com.topjohnwu.superuser.io.SuFile;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String dlString(String url) {
|
||||
String s = (String) AndroidNetworking.get(url).build().executeForString().getResult();
|
||||
String s = Networking.get(url).execForString().getResult();
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user