From b72004e9cc2f1c562ae87e803a4b42b12c568772 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 8 Apr 2019 15:46:44 -0400 Subject: [PATCH] Move methods --- app/src/main/java/com/topjohnwu/magisk/FlashActivity.java | 3 ++- .../java/com/topjohnwu/magisk/dialogs/EnvFixDialog.java | 8 ++------ .../com/topjohnwu/magisk/fragments/ModulesFragment.java | 3 ++- .../main/java/com/topjohnwu/magisk/utils/RootUtils.java | 4 ++++ app/src/main/java/com/topjohnwu/magisk/utils/Utils.java | 5 ----- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java b/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java index b77477f81..974f2dfb4 100644 --- a/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/FlashActivity.java @@ -17,6 +17,7 @@ import com.topjohnwu.magisk.adapters.StringListAdapter; import com.topjohnwu.magisk.components.BaseActivity; import com.topjohnwu.magisk.tasks.FlashZip; import com.topjohnwu.magisk.tasks.MagiskInstaller; +import com.topjohnwu.magisk.utils.RootUtils; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.superuser.CallbackList; import com.topjohnwu.superuser.Shell; @@ -47,7 +48,7 @@ public class FlashActivity extends BaseActivity { @OnClick(R.id.reboot) void reboot() { - Utils.reboot(); + RootUtils.reboot(); } @OnClick(R.id.save_logs) diff --git a/app/src/main/java/com/topjohnwu/magisk/dialogs/EnvFixDialog.java b/app/src/main/java/com/topjohnwu/magisk/dialogs/EnvFixDialog.java index 93a7efd13..9c7328bba 100644 --- a/app/src/main/java/com/topjohnwu/magisk/dialogs/EnvFixDialog.java +++ b/app/src/main/java/com/topjohnwu/magisk/dialogs/EnvFixDialog.java @@ -2,22 +2,18 @@ package com.topjohnwu.magisk.dialogs; import android.app.Activity; import android.app.ProgressDialog; -import android.content.Intent; import android.widget.Toast; import androidx.annotation.NonNull; -import com.topjohnwu.magisk.ClassMap; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.SplashActivity; import com.topjohnwu.magisk.tasks.MagiskInstaller; +import com.topjohnwu.magisk.utils.RootUtils; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.internal.UiThreadHandler; import com.topjohnwu.superuser.io.SuFile; -import java.io.IOException; - public class EnvFixDialog extends CustomAlertDialog { public EnvFixDialog(@NonNull Activity activity) { @@ -42,7 +38,7 @@ public class EnvFixDialog extends CustomAlertDialog { pd.dismiss(); Utils.toast(success ? R.string.reboot_delay_toast : R.string.setup_fail, Toast.LENGTH_LONG); if (success) - UiThreadHandler.handler.postDelayed(Utils::reboot, 5000); + UiThreadHandler.handler.postDelayed(RootUtils::reboot, 5000); } }.exec(); }); diff --git a/app/src/main/java/com/topjohnwu/magisk/fragments/ModulesFragment.java b/app/src/main/java/com/topjohnwu/magisk/fragments/ModulesFragment.java index 768672fd0..81babd61d 100644 --- a/app/src/main/java/com/topjohnwu/magisk/fragments/ModulesFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/fragments/ModulesFragment.java @@ -25,6 +25,7 @@ import com.topjohnwu.magisk.adapters.ModulesAdapter; import com.topjohnwu.magisk.components.BaseFragment; import com.topjohnwu.magisk.container.Module; import com.topjohnwu.magisk.utils.Event; +import com.topjohnwu.magisk.utils.RootUtils; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.superuser.Shell; @@ -110,7 +111,7 @@ public class ModulesFragment extends BaseFragment { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.reboot: - Utils.reboot(); + RootUtils.reboot(); return true; case R.id.reboot_recovery: Shell.su("/system/bin/reboot recovery").submit(); diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/RootUtils.java b/app/src/main/java/com/topjohnwu/magisk/utils/RootUtils.java index c70c59913..b11d1ba3e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/RootUtils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/RootUtils.java @@ -20,6 +20,10 @@ public class RootUtils extends Shell.Initializer { Shell.su(Utils.fmt("(rm_launch %s %s)&", rm, component.flattenToString())).exec(); } + public static void reboot() { + Shell.su("/system/bin/reboot" + (Config.recovery ? " recovery" : "")).submit(); + } + @Override public boolean onInit(Context context, @NonNull Shell shell) { Shell.Job job = shell.newJob(); diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index d7f18fd60..4da21aab3 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -27,7 +27,6 @@ import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.components.UpdateCheckService; import com.topjohnwu.magisk.container.Module; import com.topjohnwu.magisk.container.ValueSortedMap; -import com.topjohnwu.magisk.tasks.CheckUpdates; import com.topjohnwu.net.Networking; import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.internal.UiThreadHandler; @@ -136,10 +135,6 @@ public class Utils { Config.Value.MULTIUSER_MODE_OWNER_MANAGED); } - public static void reboot() { - Shell.su("/system/bin/reboot" + (Config.recovery ? " recovery" : "")).submit(); - } - public static boolean isCanary() { return BuildConfig.VERSION_NAME.contains("-"); }