use of com.topjohnwu.magisk.asyncs.RestoreImages in project MagiskManager by topjohnwu.
the class ShowUI method uninstallDialog.
public static void uninstallDialog(Activity activity) {
MagiskManager mm = Utils.getMagiskManager(activity);
new AlertDialogBuilder(activity).setTitle(R.string.uninstall_magisk_title).setMessage(R.string.uninstall_magisk_msg).setPositiveButton(R.string.complete_uninstall, (d, i) -> {
ByteArrayOutputStream uninstaller = new ByteArrayOutputStream();
try (InputStream in = mm.getAssets().open(Const.UNINSTALLER)) {
ShellUtils.pump(in, uninstaller);
} catch (IOException e) {
e.printStackTrace();
return;
}
ByteArrayOutputStream utils = new ByteArrayOutputStream();
try (InputStream in = mm.getAssets().open(Const.UTIL_FUNCTIONS)) {
ShellUtils.pump(in, utils);
} catch (IOException e) {
e.printStackTrace();
return;
}
Shell.Sync.su(Utils.fmt("echo '%s' > /cache/%s", uninstaller.toString().replace("'", "'\\''"), Const.UNINSTALLER), Utils.fmt("echo '%s' > %s/%s", utils.toString().replace("'", "'\\''"), mm.magiskVersionCode >= 1464 ? "/data/adb/magisk" : "/data/magisk", Const.UTIL_FUNCTIONS));
try {
uninstaller.close();
utils.close();
} catch (IOException ignored) {
}
MagiskManager.toast(R.string.uninstall_toast, Toast.LENGTH_LONG);
new Handler().postDelayed(() -> Utils.uninstallPkg(mm.getPackageName()), 5000);
}).setNeutralButton(R.string.restore_img, (d, i) -> new RestoreImages().exec()).setNegativeButton(R.string.uninstall_app, (d, i) -> Utils.uninstallPkg(mm.getPackageName())).show();
}
Aggregations