Default to beta channel if detected
This commit is contained in:
parent
7af7910e78
commit
ced9b4a8ee
@ -73,6 +73,7 @@ public class Config {
|
||||
}
|
||||
|
||||
public static class Value {
|
||||
public static final int DEFAULT_CHANNEL = -1;
|
||||
public static final int STABLE_CHANNEL = 0;
|
||||
public static final int BETA_CHANNEL = 1;
|
||||
public static final int CUSTOM_CHANNEL = 2;
|
||||
@ -316,7 +317,7 @@ public class Config {
|
||||
defs.put(Key.SU_AUTO_RESPONSE, Value.SU_PROMPT);
|
||||
defs.put(Key.SU_NOTIFICATION, Value.NOTIFICATION_TOAST);
|
||||
defs.put(Key.UPDATE_CHANNEL, Utils.isCanary() ?
|
||||
Value.CANARY_DEBUG_CHANNEL : Value.STABLE_CHANNEL);
|
||||
Value.CANARY_DEBUG_CHANNEL : Value.DEFAULT_CHANNEL);
|
||||
|
||||
// prefs bool
|
||||
defs.put(Key.CHECK_UPDATES, true);
|
||||
|
@ -15,7 +15,7 @@ public class UpdateCheckService extends DelegateWorker {
|
||||
@Override
|
||||
public ListenableWorker.Result doWork() {
|
||||
Shell.getShell();
|
||||
CheckUpdates.checkNow(this::onCheckDone);
|
||||
CheckUpdates.check(this::onCheckDone);
|
||||
return ListenableWorker.Result.success();
|
||||
}
|
||||
|
||||
|
@ -239,39 +239,34 @@ public class SettingsFragment extends BasePreferenceFragment {
|
||||
private void setSummary(String key) {
|
||||
switch (key) {
|
||||
case Config.Key.UPDATE_CHANNEL:
|
||||
int ch = Config.get(key);
|
||||
ch = ch < 0 ? Config.Value.STABLE_CHANNEL : ch;
|
||||
updateChannel.setSummary(getResources()
|
||||
.getStringArray(R.array.update_channel)
|
||||
[(int) Config.get(Config.Key.UPDATE_CHANNEL)]);
|
||||
.getStringArray(R.array.update_channel)[ch]);
|
||||
break;
|
||||
case Config.Key.ROOT_ACCESS:
|
||||
rootConfig.setSummary(getResources()
|
||||
.getStringArray(R.array.su_access)
|
||||
[(int) Config.get(Config.Key.ROOT_ACCESS)]);
|
||||
.getStringArray(R.array.su_access)[(int)Config.get(key)]);
|
||||
break;
|
||||
case Config.Key.SU_AUTO_RESPONSE:
|
||||
autoRes.setSummary(getResources()
|
||||
.getStringArray(R.array.auto_response)
|
||||
[(int) Config.get(Config.Key.SU_AUTO_RESPONSE)]);
|
||||
.getStringArray(R.array.auto_response)[(int)Config.get(key)]);
|
||||
break;
|
||||
case Config.Key.SU_NOTIFICATION:
|
||||
suNotification.setSummary(getResources()
|
||||
.getStringArray(R.array.su_notification)
|
||||
[(int) Config.get(Config.Key.SU_NOTIFICATION)]);
|
||||
.getStringArray(R.array.su_notification)[(int)Config.get(key)]);
|
||||
break;
|
||||
case Config.Key.SU_REQUEST_TIMEOUT:
|
||||
requestTimeout.setSummary(
|
||||
getString(R.string.request_timeout_summary,
|
||||
(int) Config.get(Config.Key.SU_REQUEST_TIMEOUT)));
|
||||
getString(R.string.request_timeout_summary, (int)Config.get(key)));
|
||||
break;
|
||||
case Config.Key.SU_MULTIUSER_MODE:
|
||||
multiuserConfig.setSummary(getResources()
|
||||
.getStringArray(R.array.multiuser_summary)
|
||||
[(int) Config.get(Config.Key.SU_MULTIUSER_MODE)]);
|
||||
.getStringArray(R.array.multiuser_summary)[(int)Config.get(key)]);
|
||||
break;
|
||||
case Config.Key.SU_MNT_NS:
|
||||
nsConfig.setSummary(getResources()
|
||||
.getStringArray(R.array.namespace_summary)
|
||||
[(int) Config.get(Config.Key.SU_MNT_NS)]);
|
||||
.getStringArray(R.array.namespace_summary)[(int)Config.get(key)]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.topjohnwu.magisk.utils.Event;
|
||||
import com.topjohnwu.net.Networking;
|
||||
import com.topjohnwu.net.Request;
|
||||
import com.topjohnwu.net.ResponseListener;
|
||||
import com.topjohnwu.superuser.ShellUtils;
|
||||
import com.topjohnwu.superuser.internal.UiThreadHandler;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -30,7 +31,6 @@ public class CheckUpdates {
|
||||
case Config.Value.CANARY_DEBUG_CHANNEL:
|
||||
url = Const.Url.CANARY_DEBUG_URL;
|
||||
break;
|
||||
case Config.Value.STABLE_CHANNEL:
|
||||
default:
|
||||
url = Const.Url.STABLE_URL;
|
||||
break;
|
||||
@ -39,13 +39,19 @@ public class CheckUpdates {
|
||||
}
|
||||
|
||||
public static void check() {
|
||||
getRequest().getAsJSONObject(new UpdateListener(null));
|
||||
check(null);
|
||||
}
|
||||
|
||||
public static void checkNow(Runnable cb) {
|
||||
JSONObject json = getRequest().execForJSONObject().getResult();
|
||||
if (json != null)
|
||||
new UpdateListener(cb).onResponse(json);
|
||||
public static void check(Runnable cb) {
|
||||
Request request = getRequest();
|
||||
UpdateListener listener = new UpdateListener(cb);
|
||||
if (ShellUtils.onMainThread()) {
|
||||
request.getAsJSONObject(listener);
|
||||
} else {
|
||||
JSONObject json = request.execForJSONObject().getResult();
|
||||
if (json != null)
|
||||
listener.onResponse(json);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UpdateListener implements ResponseListener<JSONObject> {
|
||||
@ -89,8 +95,20 @@ public class CheckUpdates {
|
||||
@Override
|
||||
public void onResponse(JSONObject json) {
|
||||
JSONObject magisk = getJson(json, "magisk");
|
||||
Config.remoteMagiskVersionString = getString(magisk, "version", null);
|
||||
Config.remoteMagiskVersionCode = getInt(magisk, "versionCode", -1);
|
||||
|
||||
if ((int) Config.get(Config.Key.UPDATE_CHANNEL) == Config.Value.DEFAULT_CHANNEL) {
|
||||
if (Config.magiskVersionCode > Config.remoteMagiskVersionCode) {
|
||||
// If we are newer than current stable channel, switch to beta
|
||||
Config.set(Config.Key.UPDATE_CHANNEL, Config.Value.BETA_CHANNEL);
|
||||
check(cb);
|
||||
return;
|
||||
} else {
|
||||
Config.set(Config.Key.UPDATE_CHANNEL, Config.Value.STABLE_CHANNEL);
|
||||
}
|
||||
}
|
||||
|
||||
Config.remoteMagiskVersionString = getString(magisk, "version", null);
|
||||
Config.magiskLink = getString(magisk, "link", null);
|
||||
Config.magiskNoteLink = getString(magisk, "note", null);
|
||||
Config.magiskMD5 = getString(magisk, "md5", null);
|
||||
|
@ -155,7 +155,7 @@
|
||||
<string name="auto_response">Automatická odpoveď</string>
|
||||
<string name="request_timeout">Časový limit pre odpoveď</string>
|
||||
<string name="superuser_notification">Notifikácie Superuser</string>
|
||||
<string name="request_timeout_summary">%1$s sekúnd</string>
|
||||
<string name="request_timeout_summary">%1$d sekúnd</string>
|
||||
<string name="settings_su_reauth_title">Overenie autentifikácie po upgrade</string>
|
||||
<string name="settings_su_reauth_summary">Overí autentifikáciu oprávnení superuser po upgrade aplikácie</string>
|
||||
<string name="settings_su_fingerprint_title">Povoliť autentifikáciu odtlačkom prsta</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user