Introduce new debug channel

This commit is contained in:
topjohnwu 2022-05-15 01:01:54 -07:00
parent 071ae79fa8
commit dc65a2b884
5 changed files with 16 additions and 8 deletions

View File

@ -70,6 +70,7 @@ object Config : PreferenceModel, DBConfig {
const val BETA_CHANNEL = 1 const val BETA_CHANNEL = 1
const val CUSTOM_CHANNEL = 2 const val CUSTOM_CHANNEL = 2
const val CANARY_CHANNEL = 3 const val CANARY_CHANNEL = 3
const val DEBUG_CHANNEL = 4
// root access mode // root access mode
const val ROOT_ACCESS_DISABLED = 0 const val ROOT_ACCESS_DISABLED = 0
@ -106,6 +107,8 @@ object Config : PreferenceModel, DBConfig {
private val defaultChannel = private val defaultChannel =
if (BuildConfig.DEBUG) if (BuildConfig.DEBUG)
Value.DEBUG_CHANNEL
else if (Const.APP_IS_CANARY)
Value.CANARY_CHANNEL Value.CANARY_CHANNEL
else else
Value.DEFAULT_CHANNEL Value.DEFAULT_CHANNEL

View File

@ -4,6 +4,7 @@ import com.topjohnwu.magisk.core.Config
import com.topjohnwu.magisk.core.Config.Value.BETA_CHANNEL import com.topjohnwu.magisk.core.Config.Value.BETA_CHANNEL
import com.topjohnwu.magisk.core.Config.Value.CANARY_CHANNEL import com.topjohnwu.magisk.core.Config.Value.CANARY_CHANNEL
import com.topjohnwu.magisk.core.Config.Value.CUSTOM_CHANNEL import com.topjohnwu.magisk.core.Config.Value.CUSTOM_CHANNEL
import com.topjohnwu.magisk.core.Config.Value.DEBUG_CHANNEL
import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL import com.topjohnwu.magisk.core.Config.Value.DEFAULT_CHANNEL
import com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL import com.topjohnwu.magisk.core.Config.Value.STABLE_CHANNEL
import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.Info
@ -24,12 +25,12 @@ class NetworkService(
DEFAULT_CHANNEL, STABLE_CHANNEL -> fetchStableUpdate() DEFAULT_CHANNEL, STABLE_CHANNEL -> fetchStableUpdate()
BETA_CHANNEL -> fetchBetaUpdate() BETA_CHANNEL -> fetchBetaUpdate()
CANARY_CHANNEL -> fetchCanaryUpdate() CANARY_CHANNEL -> fetchCanaryUpdate()
DEBUG_CHANNEL -> fetchDebugUpdate()
CUSTOM_CHANNEL -> fetchCustomUpdate(Config.customChannelUrl) CUSTOM_CHANNEL -> fetchCustomUpdate(Config.customChannelUrl)
else -> throw IllegalArgumentException() else -> throw IllegalArgumentException()
} }
if (info.magisk.versionCode < Info.env.versionCode && if (info.magisk.versionCode < Info.env.versionCode &&
Config.updateChannel == DEFAULT_CHANNEL Config.updateChannel == DEFAULT_CHANNEL) {
) {
Config.updateChannel = BETA_CHANNEL Config.updateChannel = BETA_CHANNEL
info = fetchBetaUpdate() info = fetchBetaUpdate()
} }
@ -40,6 +41,7 @@ class NetworkService(
private suspend fun fetchStableUpdate() = pages.fetchUpdateJSON("stable.json") private suspend fun fetchStableUpdate() = pages.fetchUpdateJSON("stable.json")
private suspend fun fetchBetaUpdate() = pages.fetchUpdateJSON("beta.json") private suspend fun fetchBetaUpdate() = pages.fetchUpdateJSON("beta.json")
private suspend fun fetchCanaryUpdate() = pages.fetchUpdateJSON("canary.json") private suspend fun fetchCanaryUpdate() = pages.fetchUpdateJSON("canary.json")
private suspend fun fetchDebugUpdate() = pages.fetchUpdateJSON("debug.json")
private suspend fun fetchCustomUpdate(url: String) = raw.fetchCustomUpdate(url) private suspend fun fetchCustomUpdate(url: String) = raw.fetchCustomUpdate(url)
private inline fun <T> safe(factory: () -> T): T? { private inline fun <T> safe(factory: () -> T): T? {

View File

@ -65,6 +65,7 @@
<item>@string/settings_update_beta</item> <item>@string/settings_update_beta</item>
<item>@string/settings_update_custom</item> <item>@string/settings_update_custom</item>
<item>Canary</item> <item>Canary</item>
<item>Debug</item>
</string-array> </string-array>
</resources> </resources>

View File

@ -275,8 +275,8 @@ def write_if_diff(file_name, text):
f.write(text) f.write(text)
def dump_bin_header(): def dump_bin_header(args):
stub = op.join(config['outdir'], 'stub-release.apk') stub = op.join(config['outdir'], f'stub-{"release" if args.release else "debug"}.apk')
if not op.exists(stub): if not op.exists(stub):
error('Build stub APK before building "magiskinit"') error('Build stub APK before building "magiskinit"')
mkdir_p(native_gen_path) mkdir_p(native_gen_path)
@ -353,7 +353,7 @@ def build_binary(args):
flag = '' flag = ''
if 'magiskinit' in args.target: if 'magiskinit' in args.target:
dump_bin_header() dump_bin_header(args)
flag += ' B_INIT=1' flag += ' B_INIT=1'
if 'resetprop' in args.target: if 'resetprop' in args.target:
@ -370,7 +370,7 @@ def build_binary(args):
def build_apk(args, module): def build_apk(args, module):
build_type = 'Release' if args.release or module == 'stub' else 'Debug' build_type = 'Release' if args.release else 'Debug'
proc = execv([gradlew, f'{module}:assemble{build_type}', proc = execv([gradlew, f'{module}:assemble{build_type}',
'-PconfigPath=' + op.abspath(args.config)]) '-PconfigPath=' + op.abspath(args.config)])

View File

@ -40,7 +40,9 @@ import io.michaelrocks.paranoid.Obfuscate;
public class DownloadActivity extends Activity { public class DownloadActivity extends Activity {
private static final String APP_NAME = "Magisk"; private static final String APP_NAME = "Magisk";
private static final String CANARY_URL = "https://topjohnwu.github.io/magisk-files/canary.json"; private static final String JSON_URL = BuildConfig.DEBUG ?
"https://topjohnwu.github.io/magisk-files/debug.json" :
"https://topjohnwu.github.io/magisk-files/canary.json";
private String apkLink = BuildConfig.APK_URL; private String apkLink = BuildConfig.APK_URL;
private Context themed; private Context themed;
@ -105,7 +107,7 @@ public class DownloadActivity extends Activity {
private void fetchCanary() { private void fetchCanary() {
dialog = ProgressDialog.show(themed, "", "", true); dialog = ProgressDialog.show(themed, "", "", true);
request(CANARY_URL).getAsJSONObject(json -> { request(JSON_URL).getAsJSONObject(json -> {
dialog.dismiss(); dialog.dismiss();
try { try {
apkLink = json.getJSONObject("magisk").getString("link"); apkLink = json.getJSONObject("magisk").getString("link");