diff --git a/app-core/build.gradle b/app-core/build.gradle index c47fbebed..6334dc55e 100644 --- a/app-core/build.gradle +++ b/app-core/build.gradle @@ -15,7 +15,7 @@ dependencies { api project(':signing') api 'org.kamranzafar:jtar:2.3' - def libsuVersion = '2.2.0' + def libsuVersion = 'd99f481563' api "com.github.topjohnwu.libsu:core:${libsuVersion}" api "com.github.topjohnwu.libsu:io:${libsuVersion}" } diff --git a/app-core/src/main/java/com/topjohnwu/magisk/App.java b/app-core/src/main/java/com/topjohnwu/magisk/App.java index 3849cbacd..aaf3d52bb 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/App.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/App.java @@ -3,9 +3,6 @@ package com.topjohnwu.magisk; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; -import android.content.res.Resources; -import android.os.Handler; -import android.os.Looper; import android.preference.PreferenceManager; import com.topjohnwu.magisk.core.BuildConfig; @@ -20,7 +17,6 @@ import com.topjohnwu.superuser.Shell; public class App extends ContainerApp { public static App self; - public static Handler mainHandler = new Handler(Looper.getMainLooper()); public boolean init = false; // Global resources diff --git a/app-core/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java b/app-core/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java index 94ec43056..d55702f65 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java @@ -5,10 +5,10 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; -import com.topjohnwu.magisk.App; import com.topjohnwu.magisk.Config; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.container.Repo; +import com.topjohnwu.superuser.internal.UiThreadHandler; import java.util.HashSet; import java.util.Set; @@ -127,7 +127,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper { private void notifyAdapter() { if (adapterCb != null) { - App.mainHandler.post(adapterCb); + UiThreadHandler.run(adapterCb); } } } diff --git a/app-core/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.java b/app-core/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.java index d81a746ae..68353face 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/tasks/FlashZip.java @@ -9,6 +9,7 @@ import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.ZipUtils; import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.ShellUtils; +import com.topjohnwu.superuser.internal.UiThreadHandler; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -76,7 +77,7 @@ public abstract class FlashZip { } catch (IOException ignored) {} Shell.su("cd /", "rm -rf " + tmpFile.getParent() + " " + Const.TMP_FOLDER_PATH).submit(); boolean finalSuccess = success; - App.mainHandler.post(() -> onResult(finalSuccess)); + UiThreadHandler.run(() -> onResult(finalSuccess)); }); } diff --git a/app-core/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java b/app-core/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java index 05d5bf111..9dbb683f2 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java @@ -17,6 +17,7 @@ import com.topjohnwu.signing.SignBoot; import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.ShellUtils; import com.topjohnwu.superuser.internal.NOPList; +import com.topjohnwu.superuser.internal.UiThreadHandler; import com.topjohnwu.superuser.io.SuFile; import com.topjohnwu.superuser.io.SuFileInputStream; import com.topjohnwu.superuser.io.SuFileOutputStream; @@ -309,7 +310,7 @@ public abstract class MagiskInstaller { public void exec() { AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> { boolean b = operations(); - App.mainHandler.post(() -> onResult(b)); + UiThreadHandler.run(() -> onResult(b)); }); } diff --git a/app-core/src/main/java/com/topjohnwu/magisk/utils/Topic.java b/app-core/src/main/java/com/topjohnwu/magisk/utils/Topic.java index ef267aa4a..7cfbf1ba0 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/utils/Topic.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/utils/Topic.java @@ -1,6 +1,6 @@ package com.topjohnwu.magisk.utils; -import com.topjohnwu.magisk.App; +import com.topjohnwu.superuser.internal.UiThreadHandler; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -64,7 +64,7 @@ public class Topic { topicList[topic].published = true; } for (Subscriber sub : topicList[topic].subscribers) { - App.mainHandler.post(() -> sub.onPublish(topic, results)); + UiThreadHandler.run(() -> sub.onPublish(topic, results)); } } diff --git a/app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java index 223bb0544..fec2b70b1 100644 --- a/app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -20,6 +20,7 @@ import com.topjohnwu.magisk.container.Module; import com.topjohnwu.magisk.container.ValueSortedMap; import com.topjohnwu.net.Networking; import com.topjohnwu.superuser.Shell; +import com.topjohnwu.superuser.internal.UiThreadHandler; import com.topjohnwu.superuser.io.SuFile; import java.util.Locale; @@ -28,11 +29,11 @@ import java.util.Map; public class Utils { public static void toast(CharSequence msg, int duration) { - App.mainHandler.post(() -> Toast.makeText(App.self, msg, duration).show()); + UiThreadHandler.run(() -> Toast.makeText(App.self, msg, duration).show()); } public static void toast(int resId, int duration) { - App.mainHandler.post(() -> Toast.makeText(App.self, resId, duration).show()); + UiThreadHandler.run(() -> Toast.makeText(App.self, resId, duration).show()); } public static String dlString(String url) { diff --git a/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java b/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java index a7b47c57d..095bbefca 100644 --- a/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java @@ -15,6 +15,7 @@ import com.topjohnwu.magisk.tasks.MagiskInstaller; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.superuser.CallbackList; import com.topjohnwu.superuser.Shell; +import com.topjohnwu.superuser.internal.UiThreadHandler; import java.io.File; import java.io.FileWriter; @@ -180,7 +181,7 @@ public class FlashActivity extends BaseActivity { @Override public String set(int i, String s) { String ret = super.set(i, s); - App.mainHandler.post(this::updateUI); + UiThreadHandler.run(this::updateUI); return ret; } } @@ -212,7 +213,7 @@ public class FlashActivity extends BaseActivity { @Override protected void onResult(boolean success) { if (success) - App.mainHandler.postDelayed(Shell.su("pm uninstall " + getPackageName())::exec, 3000); + UiThreadHandler.handler.postDelayed(Shell.su("pm uninstall " + getPackageName())::exec, 3000); else super.onResult(false); } diff --git a/app/src/full/java/com/topjohnwu/magisk/components/BaseActivity.java b/app/src/full/java/com/topjohnwu/magisk/components/BaseActivity.java index 4fababa45..5fb822807 100644 --- a/app/src/full/java/com/topjohnwu/magisk/components/BaseActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/components/BaseActivity.java @@ -4,7 +4,6 @@ import android.Manifest; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import android.content.res.Configuration; import android.os.Bundle; import android.view.WindowManager; import android.widget.Toast;