Removed events from modules / replaced with retrofit/rx

This commit is contained in:
Viktor De Pasquale
2019-05-07 15:41:56 +02:00
parent 10e903c9fc
commit 7c755a3991
17 changed files with 116 additions and 223 deletions

View File

@@ -27,6 +27,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import androidx.annotation.WorkerThread;
import androidx.work.Constraints;
import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.NetworkType;
@@ -84,22 +85,16 @@ public class Utils {
.replace("#", "").replace("@", "").replace("\\", "_");
}
@Deprecated
public static void loadModules() {
loadModules(true);
}
@Deprecated
public static void loadModules(boolean async) {
Event.reset(Event.MODULE_LOAD_DONE);
Runnable run = () -> {
Map<String, OldModule> moduleMap = new ValueSortedMap<>();
SuFile path = new SuFile(Const.MAGISK_PATH);
SuFile[] modules = path.listFiles(
(file, name) -> !name.equals("lost+found") && !name.equals(".core"));
for (SuFile file : modules) {
if (file.isFile()) continue;
OldModule module = new OldModule(Const.MAGISK_PATH + "/" + file.getName());
moduleMap.put(module.getId(), module);
}
Map<String, OldModule> moduleMap = loadModulesLeanback();
Event.trigger(Event.MODULE_LOAD_DONE, moduleMap);
};
if (async)
@@ -108,6 +103,21 @@ public class Utils {
run.run();
}
@WorkerThread
public static Map<String, OldModule> loadModulesLeanback() {
final Map<String, OldModule> moduleMap = new ValueSortedMap<>();
final SuFile path = new SuFile(Const.MAGISK_PATH);
final SuFile[] modules = path.listFiles((file, name) ->
!name.equals("lost+found") && !name.equals(".core")
);
for (SuFile file : modules) {
if (file.isFile()) continue;
OldModule module = new OldModule(Const.MAGISK_PATH + "/" + file.getName());
moduleMap.put(module.getId(), module);
}
return moduleMap;
}
public static boolean showSuperUser() {
return Shell.rootAccess() && (Const.USER_ID == 0 ||
(int) Config.get(Config.Key.SU_MULTIUSER_MODE) !=

View File

@@ -14,5 +14,5 @@ fun String.toTime(format: SimpleDateFormat) = try {
}
private val locale get() = Locale.getDefault()
val timeFormatFull by lazy { SimpleDateFormat("YYYY/MM/DD_HH:mm:ss", locale) }
val timeFormatStandard by lazy { SimpleDateFormat("YYYY-MM-DD'T'HH:mm:ss'Z'", locale) }
val timeFormatFull by lazy { SimpleDateFormat("yyyy/MM/dd_HH:mm:ss", locale) }
val timeFormatStandard by lazy { SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", locale) }