mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:37:49 +00:00
Fix FlashZip (again...)
This commit is contained in:
parent
b3e2a6a860
commit
6ef47249ab
@ -70,6 +70,44 @@ public class MagiskFragment extends Fragment {
|
|||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
private SharedPreferences.OnSharedPreferenceChangeListener listener;
|
||||||
|
|
||||||
|
private AlertDialog.OnClickListener flashMagisk = (dialogInterface, i) -> Utils.downloadAndReceive(
|
||||||
|
getActivity(),
|
||||||
|
new DownloadReceiver("Magisk-v" + String.valueOf(remoteMagiskVersion)) {
|
||||||
|
@Override
|
||||||
|
public void task(Uri uri) {
|
||||||
|
new Async.FlashZIP(mContext, uri, mName) {
|
||||||
|
@Override
|
||||||
|
protected void preProcessing() throws Throwable {
|
||||||
|
super.preProcessing();
|
||||||
|
new File(mUri.getPath()).delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
Shell.su("setprop magisk.version " + String.valueOf(remoteMagiskVersion));
|
||||||
|
super.done();
|
||||||
|
}
|
||||||
|
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
magiskLink,
|
||||||
|
"latest_magisk.zip");
|
||||||
|
|
||||||
|
private AlertDialog.OnClickListener installMagiskApk = (dialogInterface, i) -> Utils.downloadAndReceive(
|
||||||
|
getActivity(),
|
||||||
|
new DownloadReceiver() {
|
||||||
|
@Override
|
||||||
|
public void task(Uri uri) {
|
||||||
|
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
||||||
|
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
Uri content = FileProvider.getUriForFile(getActivity(), "com.topjohnwu.magisk.provider", new File(uri.getPath()));
|
||||||
|
install.setData(content);
|
||||||
|
mContext.startActivity(install);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appLink,
|
||||||
|
"MagiskManager-v" + remoteAppVersion + ".apk");
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
@ -180,16 +218,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
.setTitle(getString(R.string.update_title, getString(R.string.magisk)))
|
.setTitle(getString(R.string.update_title, getString(R.string.magisk)))
|
||||||
.setMessage(getString(R.string.update_msg, getString(R.string.magisk), String.valueOf(remoteMagiskVersion), magiskChangelog))
|
.setMessage(getString(R.string.update_msg, getString(R.string.magisk), String.valueOf(remoteMagiskVersion), magiskChangelog))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
.setPositiveButton(R.string.download_install, flashMagisk)
|
||||||
getActivity(),
|
|
||||||
new DownloadReceiver() {
|
|
||||||
@Override
|
|
||||||
public void task(Uri uri) {
|
|
||||||
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
magiskLink,
|
|
||||||
"Magisk-v" + String.valueOf(remoteMagiskVersion) + ".zip"))
|
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show());
|
.show());
|
||||||
|
|
||||||
@ -202,16 +231,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
.setTitle(getString(R.string.repo_install_title, getString(R.string.magisk)))
|
.setTitle(getString(R.string.repo_install_title, getString(R.string.magisk)))
|
||||||
.setMessage(getString(R.string.repo_install_msg, "Magisk-v" + String.valueOf(remoteMagiskVersion)))
|
.setMessage(getString(R.string.repo_install_msg, "Magisk-v" + String.valueOf(remoteMagiskVersion)))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
.setPositiveButton(R.string.download_install, flashMagisk)
|
||||||
getActivity(),
|
|
||||||
new DownloadReceiver() {
|
|
||||||
@Override
|
|
||||||
public void task(Uri uri) {
|
|
||||||
new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
magiskLink,
|
|
||||||
"Magisk-v" + String.valueOf(remoteMagiskVersion) + ".zip"))
|
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show());
|
.show());
|
||||||
}
|
}
|
||||||
@ -225,19 +245,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
.setTitle(getString(R.string.update_title, getString(R.string.app_name)))
|
||||||
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), remoteAppVersion, appChangelog))
|
.setMessage(getString(R.string.update_msg, getString(R.string.app_name), remoteAppVersion, appChangelog))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(getActivity(),
|
.setPositiveButton(R.string.download_install, installMagiskApk)
|
||||||
new DownloadReceiver() {
|
|
||||||
@Override
|
|
||||||
public void task(Uri uri) {
|
|
||||||
Intent install = new Intent(Intent.ACTION_INSTALL_PACKAGE);
|
|
||||||
install.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
Uri content = FileProvider.getUriForFile(getActivity(), "com.topjohnwu.magisk.provider", new File(uri.getPath()));
|
|
||||||
install.setData(content);
|
|
||||||
mContext.startActivity(install);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
appLink,
|
|
||||||
"MagiskManager-v" + remoteAppVersion + ".apk"))
|
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show()
|
.show()
|
||||||
);
|
);
|
||||||
@ -259,22 +267,7 @@ public class MagiskFragment extends Fragment {
|
|||||||
.setTitle(R.string.no_magisk_title)
|
.setTitle(R.string.no_magisk_title)
|
||||||
.setMessage(R.string.no_magisk_msg)
|
.setMessage(R.string.no_magisk_msg)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive(
|
.setPositiveButton(R.string.download_install, flashMagisk)
|
||||||
getActivity(),
|
|
||||||
new DownloadReceiver() {
|
|
||||||
@Override
|
|
||||||
public void task(Uri uri) {
|
|
||||||
new Async.FlashZIP(mContext, uri) {
|
|
||||||
@Override
|
|
||||||
protected void done() {
|
|
||||||
Shell.su("setprop magisk.version " + String.valueOf(remoteMagiskVersion));
|
|
||||||
super.done();
|
|
||||||
}
|
|
||||||
}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
magiskLink,
|
|
||||||
"Magisk-v" + String.valueOf(remoteMagiskVersion) + ".zip"))
|
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
@ -238,9 +238,9 @@ public class Async {
|
|||||||
}
|
}
|
||||||
ret = Shell.su(
|
ret = Shell.su(
|
||||||
"BOOTMODE=true sh " + mFile.getParent() + "/META-INF/com/google/android/update-binary dummy 1 "+ mFile.getPath(),
|
"BOOTMODE=true sh " + mFile.getParent() + "/META-INF/com/google/android/update-binary dummy 1 "+ mFile.getPath(),
|
||||||
"if [ $? -eq 0 ]; then echo true; else echo false; fi",
|
"if [ $? -eq 0 ]; then echo true; else echo false; fi"
|
||||||
"rm -rf " + mFile.getParent() + "/META-INF"
|
|
||||||
);
|
);
|
||||||
|
Shell.su("rm -rf " + mFile.getParent() + "/META-INF");
|
||||||
Logger.dev("FlashZip: Console log:");
|
Logger.dev("FlashZip: Console log:");
|
||||||
for (String line : ret) {
|
for (String line : ret) {
|
||||||
Logger.dev(line);
|
Logger.dev(line);
|
||||||
@ -261,7 +261,6 @@ public class Async {
|
|||||||
FileInputStream in = new FileInputStream(mFile);
|
FileInputStream in = new FileInputStream(mFile);
|
||||||
createFileFromInputStream(in, sdFile);
|
createFileFromInputStream(in, sdFile);
|
||||||
in.close();
|
in.close();
|
||||||
mFile.delete();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Use the badass way :)
|
// Use the badass way :)
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -271,9 +270,9 @@ public class Async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mFile.exists() && !mFile.delete()) {
|
}
|
||||||
Utils.removeFile(mFile.getPath());
|
if (mFile != null && mFile.exists() && !mFile.delete()) {
|
||||||
}
|
Utils.removeFile(mFile.getPath());
|
||||||
}
|
}
|
||||||
if (ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1))) {
|
if (ret != null && Boolean.parseBoolean(ret.get(ret.size() - 1))) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -309,7 +308,7 @@ public class Async {
|
|||||||
new LoadModules(prefs).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
new LoadModules(prefs).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
|
||||||
|
|
||||||
AlertDialog.Builder builder;
|
AlertDialog.Builder builder;
|
||||||
String theme = PreferenceManager.getDefaultSharedPreferences(mContext).getString("theme", "");
|
String theme = prefs.getString("theme", "");
|
||||||
if (theme.equals("Dark")) {
|
if (theme.equals("Dark")) {
|
||||||
builder = new AlertDialog.Builder(mContext, R.style.AlertDialog_dh);
|
builder = new AlertDialog.Builder(mContext, R.style.AlertDialog_dh);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user