Skip to content

Commit

Permalink
Update libsu
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Feb 1, 2019
1 parent da13b5d commit 28d7a7a
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
4 changes: 0 additions & 4 deletions app-core/src/main/java/com/topjohnwu/magisk/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
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;
Expand All @@ -20,7 +17,6 @@
public class App extends ContainerApp {

public static App self;
public static Handler mainHandler = new Handler(Looper.getMainLooper());
public boolean init = false;

// Global resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
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;
Expand Down Expand Up @@ -127,7 +127,7 @@ public void unregisterAdapterCallback() {

private void notifyAdapter() {
if (adapterCb != null) {
App.mainHandler.post(adapterCb);
UiThreadHandler.run(adapterCb);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void exec() {
} 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));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -309,7 +310,7 @@ protected boolean postOTA() {
public void exec() {
AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> {
boolean b = operations();
App.mainHandler.post(() -> onResult(b));
UiThreadHandler.run(() -> onResult(b));
});
}

Expand Down
4 changes: 2 additions & 2 deletions app-core/src/main/java/com/topjohnwu/magisk/utils/Topic.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -64,7 +64,7 @@ public static void publish(boolean persist, @TopicID int topic, Object... result
topicList[topic].published = true;
}
for (Subscriber sub : topicList[topic].subscribers) {
App.mainHandler.post(() -> sub.onPublish(topic, results));
UiThreadHandler.run(() -> sub.onPublish(topic, results));
}
}

Expand Down
5 changes: 3 additions & 2 deletions app-core/src/main/java/com/topjohnwu/magisk/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand All @@ -28,11 +29,11 @@
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) {
Expand Down
5 changes: 3 additions & 2 deletions app/src/full/java/com/topjohnwu/magisk/FlashActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand Down Expand Up @@ -180,7 +181,7 @@ public void onAddElement(String s) {
@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;
}
}
Expand Down Expand Up @@ -212,7 +213,7 @@ private class Uninstall extends FlashModule {
@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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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;
Expand Down

0 comments on commit 28d7a7a

Please sign in to comment.