From 45b5e89912d9514cc2f131e32eb2602be4be0ad4 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 20 Jun 2020 02:44:29 -0700 Subject: [PATCH] Remove canary debug channel All canary builds will be debug only --- .../java/com/topjohnwu/magisk/core/Config.kt | 60 +++++++++---------- .../java/com/topjohnwu/magisk/core/Info.kt | 2 - .../magisk/data/network/GithubServices.kt | 15 +++-- .../data/repository/MagiskRepository.kt | 4 +- .../magisk/ui/settings/SettingsItems.kt | 4 +- app/src/main/res/values/arrays.xml | 3 - 6 files changed, 38 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Config.kt b/app/src/main/java/com/topjohnwu/magisk/core/Config.kt index 246ccd48a..e8f425026 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Config.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Config.kt @@ -70,7 +70,6 @@ object Config : PreferenceModel, DBConfig { const val BETA_CHANNEL = 1 const val CUSTOM_CHANNEL = 2 const val CANARY_CHANNEL = 3 - const val CANARY_DEBUG_CHANNEL = 4 // root access mode const val ROOT_ACCESS_DISABLED = 0 @@ -106,12 +105,10 @@ object Config : PreferenceModel, DBConfig { } private val defaultChannel = - if (isCanaryVersion) { - if (BuildConfig.DEBUG) - Value.CANARY_DEBUG_CHANNEL - else - Value.CANARY_CHANNEL - } else Value.DEFAULT_CHANNEL + if (BuildConfig.DEBUG) + Value.CANARY_CHANNEL + else + Value.DEFAULT_CHANNEL var bootId by preference(Key.BOOT_ID, "") @@ -154,33 +151,34 @@ object Config : PreferenceModel, DBConfig { private const val SU_FINGERPRINT = "su_fingerprint" - fun initialize() = prefs.also { - if (it.getBoolean(SU_FINGERPRINT, false)) { - suBiometric = true + fun initialize() { + prefs.edit { parsePrefs() } + + prefs.edit { + // Settings migration + if (prefs.getBoolean(SU_FINGERPRINT, false)) + suBiometric = true + remove(SU_FINGERPRINT) + prefs.getString(Key.UPDATE_CHANNEL, null).also { + if (it == null) + putString(Key.UPDATE_CHANNEL, defaultChannel.toString()) + else if (it.toInt() > Value.CANARY_CHANNEL) + putString(Key.UPDATE_CHANNEL, Value.CANARY_CHANNEL.toString()) + } + + // Get actual state + putBoolean(Key.COREONLY, Const.MAGISK_DISABLE_FILE.exists()) + + // Write database configs + putString(Key.ROOT_ACCESS, rootMode.toString()) + putString(Key.SU_MNT_NS, suMntNamespaceMode.toString()) + putString(Key.SU_MULTIUSER_MODE, suMultiuserMode.toString()) + putBoolean(Key.SU_BIOMETRIC, BiometricHelper.isEnabled) } - }.edit { - parsePrefs(this) - - // Legacy stuff - remove(SU_FINGERPRINT) - - // Get actual state - putBoolean(Key.COREONLY, Const.MAGISK_DISABLE_FILE.exists()) - - // Write database configs - putString(Key.ROOT_ACCESS, rootMode.toString()) - putString(Key.SU_MNT_NS, suMntNamespaceMode.toString()) - putString(Key.SU_MULTIUSER_MODE, suMultiuserMode.toString()) - putBoolean(Key.SU_BIOMETRIC, BiometricHelper.isEnabled) - }.also { - if (!prefs.contains(Key.UPDATE_CHANNEL)) - prefs.edit().putString(Key.UPDATE_CHANNEL, defaultChannel.toString()).apply() } - private fun parsePrefs(editor: SharedPreferences.Editor) = editor.apply { - val config = SuFile.open("/data/adb", - Const.MANAGER_CONFIGS - ) + private fun SharedPreferences.Editor.parsePrefs() { + val config = SuFile.open("/data/adb", Const.MANAGER_CONFIGS) if (config.exists()) runCatching { val input = SuFileInputStream(config) val parser = Xml.newPullParser() diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt index b45265595..e036bd318 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt @@ -1,7 +1,6 @@ package com.topjohnwu.magisk.core import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork -import com.topjohnwu.magisk.BuildConfig import com.topjohnwu.magisk.DynAPK import com.topjohnwu.magisk.core.model.UpdateInfo import com.topjohnwu.magisk.extensions.get @@ -14,7 +13,6 @@ import java.io.FileInputStream import java.io.IOException val isRunningAsStub get() = Info.stub != null -val isCanaryVersion = !BuildConfig.VERSION_NAME.contains(".") object Info { diff --git a/app/src/main/java/com/topjohnwu/magisk/data/network/GithubServices.kt b/app/src/main/java/com/topjohnwu/magisk/data/network/GithubServices.kt index ad6858507..86100e2c1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/network/GithubServices.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/network/GithubServices.kt @@ -19,11 +19,8 @@ interface GithubRawServices { @GET("$MAGISK_FILES/master/beta.json") fun fetchBetaUpdate(): Single - @GET("$MAGISK_FILES/canary/release.json") - fun fetchCanaryUpdate(): Single - @GET("$MAGISK_FILES/canary/debug.json") - fun fetchCanaryDebugUpdate(): Single + fun fetchCanaryUpdate(): Single @GET fun fetchCustomUpdate(@Url url: String): Single @@ -73,9 +70,11 @@ interface GithubRawServices { interface GithubApiServices { @GET("repos") - fun fetchRepos(@Query("page") page: Int, - @Header(Const.Key.IF_NONE_MATCH) etag: String, - @Query("sort") sort: String = "pushed", - @Query("per_page") count: Int = 100): Flowable>> + fun fetchRepos( + @Query("page") page: Int, + @Header(Const.Key.IF_NONE_MATCH) etag: String, + @Query("sort") sort: String = "pushed", + @Query("per_page") count: Int = 100 + ): Flowable>> } diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/MagiskRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/MagiskRepository.kt index 1620be38a..4ffe3c648 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/MagiskRepository.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/MagiskRepository.kt @@ -23,9 +23,7 @@ class MagiskRepository( Config.Value.DEFAULT_CHANNEL, Config.Value.STABLE_CHANNEL -> apiRaw.fetchStableUpdate() Config.Value.BETA_CHANNEL -> apiRaw.fetchBetaUpdate() Config.Value.CANARY_CHANNEL -> apiRaw.fetchCanaryUpdate() - Config.Value.CANARY_DEBUG_CHANNEL -> apiRaw.fetchCanaryDebugUpdate() - Config.Value.CUSTOM_CHANNEL -> apiRaw.fetchCustomUpdate( - Config.customChannelUrl) + Config.Value.CUSTOM_CHANNEL -> apiRaw.fetchCustomUpdate(Config.customChannelUrl) else -> throw IllegalArgumentException() }.flatMap { // If remote version is lower than current installed, try switching to beta diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt index 09b6ec183..6b44c5998 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsItems.kt @@ -12,7 +12,6 @@ import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Config import com.topjohnwu.magisk.core.Const import com.topjohnwu.magisk.core.Info -import com.topjohnwu.magisk.core.isCanaryVersion import com.topjohnwu.magisk.core.utils.* import com.topjohnwu.magisk.databinding.DialogSettingsAppNameBinding import com.topjohnwu.magisk.databinding.DialogSettingsDownloadPathBinding @@ -141,8 +140,7 @@ object UpdateChannel : SettingsItem.Selector() { override val title = R.string.settings_update_channel_title.asTransitive() override val entries get() = resources.getStringArray(R.array.update_channel).let { - if (!isCanaryVersion && Config.updateChannel < Config.Value.CANARY_CHANNEL) - it.take(it.size - 2).toTypedArray() else it + if (BuildConfig.DEBUG) it.toMutableList().apply { add("Canary") }.toTypedArray() else it } override val entryValRes = R.array.value_array } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index c5228a019..95d5094cd 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -81,9 +81,6 @@ @string/settings_update_stable @string/settings_update_beta @string/settings_update_custom - - Canary - Canary (Debug)