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