mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 13:17:39 +02:00
Switch to WorkManager
This commit is contained in:
@ -62,6 +62,7 @@ public class Const {
|
||||
public static final int HIDE_MANAGER_NOTIFICATION_ID = 8;
|
||||
public static final String UPDATE_NOTIFICATION_CHANNEL = "update";
|
||||
public static final String PROGRESS_NOTIFICATION_CHANNEL = "progress";
|
||||
public static final String CHECK_MAGISK_UPDATE_WORKER_ID = "magisk_update";
|
||||
}
|
||||
|
||||
public static class Url {
|
||||
|
@ -5,6 +5,7 @@ import com.topjohnwu.core.Const;
|
||||
import com.topjohnwu.core.Data;
|
||||
import com.topjohnwu.core.utils.Topic;
|
||||
import com.topjohnwu.net.Networking;
|
||||
import com.topjohnwu.net.Request;
|
||||
import com.topjohnwu.net.ResponseListener;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -40,26 +41,31 @@ public class CheckUpdates {
|
||||
}
|
||||
}
|
||||
|
||||
public static void check(Runnable cb) {
|
||||
private static Request getRequest() {
|
||||
String url;
|
||||
switch (Data.updateChannel) {
|
||||
case Const.Value.STABLE_CHANNEL:
|
||||
url = Const.Url.STABLE_URL;
|
||||
break;
|
||||
case Const.Value.BETA_CHANNEL:
|
||||
url = Const.Url.BETA_URL;
|
||||
break;
|
||||
case Const.Value.CUSTOM_CHANNEL:
|
||||
url = App.self.prefs.getString(Const.Key.CUSTOM_CHANNEL, "");
|
||||
break;
|
||||
case Const.Value.STABLE_CHANNEL:
|
||||
default:
|
||||
return;
|
||||
url = Const.Url.STABLE_URL;
|
||||
break;
|
||||
}
|
||||
Networking.get(url).getAsJSONObject(new UpdateListener(cb));
|
||||
return Networking.get(url);
|
||||
}
|
||||
|
||||
public static void check() {
|
||||
check(null);
|
||||
getRequest().getAsJSONObject(new UpdateListener(null));
|
||||
}
|
||||
|
||||
public static void checkNow(Runnable cb) {
|
||||
JSONObject json = getRequest().execForJSONObject().getResult();
|
||||
if (json != null)
|
||||
new UpdateListener(cb).onResponse(json);
|
||||
}
|
||||
|
||||
private static class UpdateListener implements ResponseListener<JSONObject> {
|
||||
|
Reference in New Issue
Block a user