Search in sources :

Example 1 with RestoreImages

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();
}
Also used : Context(android.content.Context) ByteArrayOutputStream(java.io.ByteArrayOutputStream) AlertDialogBuilder(com.topjohnwu.magisk.components.AlertDialogBuilder) Uri(android.net.Uri) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) FlashActivity(com.topjohnwu.magisk.FlashActivity) RebootReceiver(com.topjohnwu.magisk.receivers.RebootReceiver) Shell(com.topjohnwu.superuser.Shell) ManagerUpdate(com.topjohnwu.magisk.receivers.ManagerUpdate) ArrayList(java.util.ArrayList) R(com.topjohnwu.magisk.R) ShellUtils(com.topjohnwu.superuser.ShellUtils) Manifest(android.Manifest) Handler(android.os.Handler) Toast(android.widget.Toast) MagiskManager(com.topjohnwu.magisk.MagiskManager) SplashActivity(com.topjohnwu.magisk.SplashActivity) RestoreImages(com.topjohnwu.magisk.asyncs.RestoreImages) NotificationManager(android.app.NotificationManager) DownloadReceiver(com.topjohnwu.magisk.receivers.DownloadReceiver) IOException(java.io.IOException) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) NotificationCompat(android.support.v4.app.NotificationCompat) Activity(android.app.Activity) InputStream(java.io.InputStream) AlertDialogBuilder(com.topjohnwu.magisk.components.AlertDialogBuilder) MagiskManager(com.topjohnwu.magisk.MagiskManager) InputStream(java.io.InputStream) Handler(android.os.Handler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) RestoreImages(com.topjohnwu.magisk.asyncs.RestoreImages)

Aggregations

Manifest (android.Manifest)1 Activity (android.app.Activity)1 NotificationManager (android.app.NotificationManager)1 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Handler (android.os.Handler)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)1 AlertDialog (android.support.v7.app.AlertDialog)1 Toast (android.widget.Toast)1 FlashActivity (com.topjohnwu.magisk.FlashActivity)1 MagiskManager (com.topjohnwu.magisk.MagiskManager)1 R (com.topjohnwu.magisk.R)1 SplashActivity (com.topjohnwu.magisk.SplashActivity)1 RestoreImages (com.topjohnwu.magisk.asyncs.RestoreImages)1 AlertDialogBuilder (com.topjohnwu.magisk.components.AlertDialogBuilder)1 DownloadReceiver (com.topjohnwu.magisk.receivers.DownloadReceiver)1 ManagerUpdate (com.topjohnwu.magisk.receivers.ManagerUpdate)1