diff --git a/app/build.gradle b/app/build.gradle index a8a5f4a60..ea292ce54 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.topjohnwu.magisk" minSdkVersion 21 targetSdkVersion 26 - versionCode 45 - versionName "5.0.5" + versionCode 46 + versionName "5.0.6" ndk { moduleName 'zipadjust' abiFilters 'x86', 'armeabi-v7a' diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java index adffc7ae2..a45d5a10c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java @@ -3,6 +3,7 @@ package com.topjohnwu.magisk; import android.animation.Animator; import android.animation.ValueAnimator; import android.app.ProgressDialog; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -142,7 +143,7 @@ public class MagiskFragment extends Fragment private boolean verity = keepVerityChkbox.isChecked(); @Override - public void onDownloadDone(Uri uri) { + public void onDownloadDone(Uri uri, Context context) { new ProcessMagiskZip(getActivity(), uri, boot, enc, verity).exec(); } }, diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java index 22aee99fe..be827b9de 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java @@ -65,9 +65,8 @@ public class ReposAdapter extends RecyclerView.Adapter mContext, new DownloadReceiver() { @Override - public void onDownloadDone(Uri uri) { - Activity activity = (Activity) mContext; - new ProcessRepoZip(activity, uri, true).exec(); + public void onDownloadDone(Uri uri, Context context) { + new ProcessRepoZip((Activity) mContext, uri, true).exec(); } }, repo.getZipUrl(), @@ -76,9 +75,8 @@ public class ReposAdapter extends RecyclerView.Adapter mContext, new DownloadReceiver() { @Override - public void onDownloadDone(Uri uri) { - Activity activity = (Activity) mContext; - new ProcessRepoZip(activity, uri, false).exec(); + public void onDownloadDone(Uri uri, Context context) { + new ProcessRepoZip((Activity) mContext, uri, false).exec(); } }, repo.getZipUrl(), diff --git a/app/src/main/java/com/topjohnwu/magisk/receivers/DownloadReceiver.java b/app/src/main/java/com/topjohnwu/magisk/receivers/DownloadReceiver.java index 726ce47fb..85149f3e5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/receivers/DownloadReceiver.java +++ b/app/src/main/java/com/topjohnwu/magisk/receivers/DownloadReceiver.java @@ -12,7 +12,6 @@ import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.utils.Utils; public abstract class DownloadReceiver extends BroadcastReceiver { - public Context mContext; public String mFilename; long downloadID; @@ -20,7 +19,6 @@ public abstract class DownloadReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - mContext = context; DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { @@ -33,7 +31,7 @@ public abstract class DownloadReceiver extends BroadcastReceiver { switch (status) { case DownloadManager.STATUS_SUCCESSFUL: Uri uri = Uri.parse(c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))); - onDownloadDone(uri); + onDownloadDone(uri, context); break; default: Toast.makeText(context, R.string.download_file_error, Toast.LENGTH_LONG).show(); @@ -54,5 +52,5 @@ public abstract class DownloadReceiver extends BroadcastReceiver { mFilename = filename; } - public abstract void onDownloadDone(Uri uri); + public abstract void onDownloadDone(Uri uri, Context context); } diff --git a/app/src/main/java/com/topjohnwu/magisk/receivers/ManagerUpdate.java b/app/src/main/java/com/topjohnwu/magisk/receivers/ManagerUpdate.java index 22bf32497..d26a1d56e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/receivers/ManagerUpdate.java +++ b/app/src/main/java/com/topjohnwu/magisk/receivers/ManagerUpdate.java @@ -18,19 +18,19 @@ public class ManagerUpdate extends BroadcastReceiver { context, new DownloadReceiver() { @Override - public void onDownloadDone(Uri uri) { + public void onDownloadDone(Uri uri, Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE); install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - Uri content = FileProvider.getUriForFile(mContext, + Uri content = FileProvider.getUriForFile(context, "com.topjohnwu.magisk.provider", new File(uri.getPath())); install.setData(content); - mContext.startActivity(install); + context.startActivity(install); } else { Intent install = new Intent(Intent.ACTION_VIEW); install.setDataAndType(uri, "application/vnd.android.package-archive"); install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(install); + context.startActivity(install); } } },