mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-12 00:13:36 +00:00
Small reorganization
This commit is contained in:
parent
59141f9bbe
commit
2b502e9a0f
@ -8,10 +8,10 @@ import android.text.TextUtils;
|
|||||||
import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
import com.topjohnwu.magisk.asyncs.CheckUpdates;
|
||||||
import com.topjohnwu.magisk.asyncs.UpdateRepos;
|
import com.topjohnwu.magisk.asyncs.UpdateRepos;
|
||||||
import com.topjohnwu.magisk.components.BaseActivity;
|
import com.topjohnwu.magisk.components.BaseActivity;
|
||||||
|
import com.topjohnwu.magisk.components.Notifications;
|
||||||
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
import com.topjohnwu.magisk.receivers.ShortcutReceiver;
|
||||||
import com.topjohnwu.magisk.utils.Download;
|
import com.topjohnwu.magisk.utils.Download;
|
||||||
import com.topjohnwu.magisk.utils.LocaleManager;
|
import com.topjohnwu.magisk.utils.LocaleManager;
|
||||||
import com.topjohnwu.magisk.utils.Notifications;
|
|
||||||
import com.topjohnwu.magisk.utils.RootUtils;
|
import com.topjohnwu.magisk.utils.RootUtils;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
|
@ -5,7 +5,7 @@ import android.os.AsyncTask;
|
|||||||
import com.topjohnwu.magisk.BuildConfig;
|
import com.topjohnwu.magisk.BuildConfig;
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.Data;
|
import com.topjohnwu.magisk.Data;
|
||||||
import com.topjohnwu.magisk.utils.Notifications;
|
import com.topjohnwu.magisk.components.Notifications;
|
||||||
import com.topjohnwu.magisk.utils.Topic;
|
import com.topjohnwu.magisk.utils.Topic;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import com.topjohnwu.magisk.FlashActivity;
|
|||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.components.BaseActivity;
|
import com.topjohnwu.magisk.components.BaseActivity;
|
||||||
import com.topjohnwu.magisk.components.NotificationProgress;
|
import com.topjohnwu.magisk.components.ProgressNotification;
|
||||||
import com.topjohnwu.magisk.container.Repo;
|
import com.topjohnwu.magisk.container.Repo;
|
||||||
import com.topjohnwu.magisk.utils.WebService;
|
import com.topjohnwu.magisk.utils.WebService;
|
||||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||||
@ -39,7 +39,7 @@ public class DownloadModule {
|
|||||||
|
|
||||||
private static void dlProcessInstall(Repo repo, boolean install) {
|
private static void dlProcessInstall(Repo repo, boolean install) {
|
||||||
File output = new File(Const.EXTERNAL_PATH, repo.getDownloadFilename());
|
File output = new File(Const.EXTERNAL_PATH, repo.getDownloadFilename());
|
||||||
NotificationProgress progress = new NotificationProgress(output.getName());
|
ProgressNotification progress = new ProgressNotification(output.getName());
|
||||||
try {
|
try {
|
||||||
MagiskManager mm = Data.MM();
|
MagiskManager mm = Data.MM();
|
||||||
File temp1 = new File(mm.getCacheDir(), "temp.zip");
|
File temp1 = new File(mm.getCacheDir(), "temp.zip");
|
||||||
@ -96,9 +96,9 @@ public class DownloadModule {
|
|||||||
|
|
||||||
private long totalBytes;
|
private long totalBytes;
|
||||||
private long bytesDownloaded;
|
private long bytesDownloaded;
|
||||||
private NotificationProgress progress;
|
private ProgressNotification progress;
|
||||||
|
|
||||||
protected ProgressInputStream(InputStream in, long size, NotificationProgress p) {
|
protected ProgressInputStream(InputStream in, long size, ProgressNotification p) {
|
||||||
super(in);
|
super(in);
|
||||||
totalBytes = size;
|
totalBytes = size;
|
||||||
progress = p;
|
progress = p;
|
||||||
|
@ -67,7 +67,7 @@ class InstallMethodDialog extends AlertDialog.Builder {
|
|||||||
a.runWithPermission(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, () -> {
|
a.runWithPermission(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, () -> {
|
||||||
String filename = Utils.fmt("Magisk-v%s(%d).zip",
|
String filename = Utils.fmt("Magisk-v%s(%d).zip",
|
||||||
Data.remoteMagiskVersionString, Data.remoteMagiskVersionCode);
|
Data.remoteMagiskVersionString, Data.remoteMagiskVersionCode);
|
||||||
NotificationProgress progress = new NotificationProgress(filename);
|
ProgressNotification progress = new ProgressNotification(filename);
|
||||||
AndroidNetworking
|
AndroidNetworking
|
||||||
.download(Data.magiskLink, Const.EXTERNAL_PATH.getPath(), filename)
|
.download(Data.magiskLink, Const.EXTERNAL_PATH.getPath(), filename)
|
||||||
.build()
|
.build()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk.components;
|
||||||
|
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
@ -13,6 +13,7 @@ import com.topjohnwu.magisk.MagiskManager;
|
|||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.SplashActivity;
|
import com.topjohnwu.magisk.SplashActivity;
|
||||||
import com.topjohnwu.magisk.receivers.GeneralReceiver;
|
import com.topjohnwu.magisk.receivers.GeneralReceiver;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
@ -7,19 +7,18 @@ import com.topjohnwu.magisk.Const;
|
|||||||
import com.topjohnwu.magisk.Data;
|
import com.topjohnwu.magisk.Data;
|
||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.utils.Notifications;
|
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
|
|
||||||
public class NotificationProgress implements DownloadProgressListener {
|
public class ProgressNotification implements DownloadProgressListener {
|
||||||
|
|
||||||
private NotificationManagerCompat mgr;
|
private NotificationManagerCompat mgr;
|
||||||
private NotificationCompat.Builder builder;
|
private NotificationCompat.Builder builder;
|
||||||
private long prevTime;
|
private long prevTime;
|
||||||
|
|
||||||
public NotificationProgress(String title) {
|
public ProgressNotification(String title) {
|
||||||
MagiskManager mm = Data.MM();
|
MagiskManager mm = Data.MM();
|
||||||
mgr = NotificationManagerCompat.from(mm);
|
mgr = NotificationManagerCompat.from(mm);
|
||||||
builder = Notifications.progress(title);
|
builder = Notifications.progress(title);
|
@ -43,7 +43,7 @@ public class UninstallDialog extends CustomAlertDialog {
|
|||||||
if (!TextUtils.isEmpty(Data.uninstallerLink)) {
|
if (!TextUtils.isEmpty(Data.uninstallerLink)) {
|
||||||
setPositiveButton(R.string.complete_uninstall, (d, i) -> {
|
setPositiveButton(R.string.complete_uninstall, (d, i) -> {
|
||||||
File zip = new File(activity.getFilesDir(), "uninstaller.zip");
|
File zip = new File(activity.getFilesDir(), "uninstaller.zip");
|
||||||
NotificationProgress progress = new NotificationProgress(zip.getName());
|
ProgressNotification progress = new ProgressNotification(zip.getName());
|
||||||
AndroidNetworking.download(Data.uninstallerLink, zip.getParent(), zip.getName())
|
AndroidNetworking.download(Data.uninstallerLink, zip.getParent(), zip.getName())
|
||||||
.build()
|
.build()
|
||||||
.setDownloadProgressListener(progress)
|
.setDownloadProgressListener(progress)
|
||||||
|
@ -5,7 +5,7 @@ import android.content.Intent;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.Data;
|
import com.topjohnwu.magisk.Data;
|
||||||
import com.topjohnwu.magisk.utils.Notifications;
|
import com.topjohnwu.magisk.components.Notifications;
|
||||||
import com.topjohnwu.superuser.Shell;
|
import com.topjohnwu.superuser.Shell;
|
||||||
import com.topjohnwu.superuser.ShellUtils;
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import com.topjohnwu.magisk.Data;
|
|||||||
import com.topjohnwu.magisk.MagiskManager;
|
import com.topjohnwu.magisk.MagiskManager;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.asyncs.PatchAPK;
|
import com.topjohnwu.magisk.asyncs.PatchAPK;
|
||||||
import com.topjohnwu.magisk.components.NotificationProgress;
|
import com.topjohnwu.magisk.components.ProgressNotification;
|
||||||
import com.topjohnwu.superuser.ShellUtils;
|
import com.topjohnwu.superuser.ShellUtils;
|
||||||
import com.topjohnwu.utils.JarMap;
|
import com.topjohnwu.utils.JarMap;
|
||||||
import com.topjohnwu.utils.SignAPK;
|
import com.topjohnwu.utils.SignAPK;
|
||||||
@ -34,7 +34,7 @@ public class DlInstallManager {
|
|||||||
public static void dlInstall(String name, ManagerDownloadListener listener) {
|
public static void dlInstall(String name, ManagerDownloadListener listener) {
|
||||||
MagiskManager mm = Data.MM();
|
MagiskManager mm = Data.MM();
|
||||||
File apk = new File(mm.getFilesDir(), "manager.apk");
|
File apk = new File(mm.getFilesDir(), "manager.apk");
|
||||||
NotificationProgress progress = new NotificationProgress(name);
|
ProgressNotification progress = new ProgressNotification(name);
|
||||||
listener.setInstances(apk, progress);
|
listener.setInstances(apk, progress);
|
||||||
AndroidNetworking
|
AndroidNetworking
|
||||||
.download(Data.managerLink, apk.getParent(), apk.getName())
|
.download(Data.managerLink, apk.getParent(), apk.getName())
|
||||||
@ -46,14 +46,14 @@ public class DlInstallManager {
|
|||||||
|
|
||||||
public abstract static class ManagerDownloadListener implements DownloadListener {
|
public abstract static class ManagerDownloadListener implements DownloadListener {
|
||||||
private File apk;
|
private File apk;
|
||||||
private NotificationProgress progress;
|
private ProgressNotification progress;
|
||||||
|
|
||||||
private void setInstances(File apk, NotificationProgress progress) {
|
private void setInstances(File apk, ProgressNotification progress) {
|
||||||
this.apk = apk;
|
this.apk = apk;
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onDownloadComplete(File apk, NotificationProgress progress);
|
public abstract void onDownloadComplete(File apk, ProgressNotification progress);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onDownloadComplete() {
|
public final void onDownloadComplete() {
|
||||||
@ -69,7 +69,7 @@ public class DlInstallManager {
|
|||||||
private static class PatchPackageName extends ManagerDownloadListener {
|
private static class PatchPackageName extends ManagerDownloadListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadComplete(File apk, NotificationProgress progress) {
|
public void onDownloadComplete(File apk, ProgressNotification progress) {
|
||||||
File patched = apk;
|
File patched = apk;
|
||||||
MagiskManager mm = Data.MM();
|
MagiskManager mm = Data.MM();
|
||||||
if (!mm.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
|
if (!mm.getPackageName().equals(BuildConfig.APPLICATION_ID)) {
|
||||||
@ -95,7 +95,7 @@ public class DlInstallManager {
|
|||||||
private static class RestoreManager extends ManagerDownloadListener {
|
private static class RestoreManager extends ManagerDownloadListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadComplete(File apk, NotificationProgress progress) {
|
public void onDownloadComplete(File apk, ProgressNotification progress) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
Data.exportPrefs();
|
Data.exportPrefs();
|
||||||
if (ShellUtils.fastCmdResult("pm install " + apk))
|
if (ShellUtils.fastCmdResult("pm install " + apk))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user