From 927b8987a1e1f48e5685a9ae5d6a6989f5589ec7 Mon Sep 17 00:00:00 2001 From: YuKongA <70465933+YuKongA@users.noreply.github.com> Date: Sat, 23 Dec 2023 13:57:08 +0800 Subject: [PATCH] DeviceInfo: Remove restrictions on regionCode selection --- .../update/logic/data/DeviceInfoHelper.kt | 278 +++++++++--------- .../yukonga/update/logic/utils/AppUtils.kt | 4 - .../top/yukonga/update/ui/MainActivity.kt | 36 +-- 3 files changed, 150 insertions(+), 168 deletions(-) diff --git a/app/src/main/java/top/yukonga/update/logic/data/DeviceInfoHelper.kt b/app/src/main/java/top/yukonga/update/logic/data/DeviceInfoHelper.kt index 60f18e56..7a7ca567 100644 --- a/app/src/main/java/top/yukonga/update/logic/data/DeviceInfoHelper.kt +++ b/app/src/main/java/top/yukonga/update/logic/data/DeviceInfoHelper.kt @@ -4,9 +4,11 @@ object DeviceInfoHelper { data class AndroidVersion(val version: String, val android: String) - data class DeviceRegions(val codeNameExt: String, val version: String) + data class DeviceRegions(val codeNameExt: String, val regionCode: String) - data class Device(val deviceName: String, val codeName: String, val deviceCode: String, val regionCode: List) + data class Device(val deviceName: String, val codeName: String, val deviceCode: String) + + private const val Xiaomi = "XM" private val androidR = AndroidVersion("11", "R") private val androidS = AndroidVersion("12", "S") @@ -24,143 +26,147 @@ object DeviceInfoHelper { private val TR = DeviceRegions("_tr_global", "TR") private val JP = DeviceRegions("_jp_global", "JP") private val IN = DeviceRegions("_in_global", "IN") + private val KR = DeviceRegions("_kr_global", "KR") - private const val Xiaomi = "XM" + private val regionCode = listOf(CN, GL, EEA, RU, TW, ID, TR, JP, IN, KR) private val devices = listOf( - Device("Redmi K30 4G", "phoenix", "GH", listOf(CN)), - Device("POCO X2", "phoenixin", "GH", listOf(IN)), - Device("Redmi K30 / K30i", "picasso", "GI", listOf(CN)), - Device("Xiaomi 10", "umi", "JB", listOf(CN, GL, EEA, RU, ID, TR, IN)), - Device("Xiaomi 10 Pro", "cmi", "JA", listOf(CN, GL, EEA)), - Device("Redmi Note 9 Pro", "joyeuse", "JZ", listOf(GL, EEA, RU, TR, ID, TW)), - Device("Redmi Note 9 Pro (India) / Note 9S / Note 10 Lite", "curtana", "JW", listOf(GL, EEA, RU, TR, IN)), - Device("Redmi Note 9 Pro Max", "excalibur", "JX", listOf(IN)), - Device("Redmi K30 Pro", "lmi", "JK", listOf(CN, GL, EEA, RU, ID, TR)), - Device("Xiaomi 10 Lite", "monet", "JI", listOf(GL, TW, EEA)), - Device("Xiaomi 10 Lite (China)", "vangogh", "JV", listOf(CN)), - Device("Redmi Note 9 / 10X 4G", "merlin", "JO", listOf(CN, GL, TW, EEA, RU, ID, TR, IN)), - Device("Redmi 10X", "atom", "JH", listOf(CN)), - Device("Redmi 10X Pro", "bomb", "JL", listOf(CN)), - Device("Xiaomi Note 10 Lite ", "toco", "FN", listOf(GL, EEA, RU, TR)), - Device("Redmi 9 / 9 Prime", "lancelot", "JC", listOf(CN, GL, EEA, RU, TR, ID, TW, IN)), - Device("POCO M2 Pro", "gram", "JP", listOf(IN)), - Device("Redmi K30 Ultra", "cezanne", "JN", listOf(CN)), - Device("Xiaomi 10 Ultra", "cas", "JJ", listOf(CN)), - Device("POCO X3 NFC", "surya", "JG", listOf(GL, EEA, RU, TR, ID, IN)), - Device("Xiaomi 10T / 10T Pro / Redmi K30S Ultra", "apollo", "JD", listOf(CN, GL, EEA, RU, TR, ID, TW, IN)), - Device("POCO M3", "citrus", "JF", listOf(GL, EEA, RU, TR, ID, TW, IN)), - Device("Redmi 9T / 9 Power / Note 9 4G", "lime", "JQ", listOf(CN, GL, EEA, RU, TR, ID, TW, IN)), - Device("Redmi Note 9", "cannon", "JE", listOf(CN)), - Device("Xiaomi 10T Lite / 10i / Redmi Note 9 Pro", "gauguin", "JS", listOf(CN, GL, EEA, TR, TW, IN)), - Device("Redmi Note 9T", "cannong", "JE", listOf(RU, GL, TW, TR, EEA)), - Device("Xiaomi 11", "venus", "KB", listOf(CN, GL, EEA, RU, TR, ID, TW)), - Device("Redmi K40 / POCO F3", "alioth", "KH", listOf(CN, GL, EEA, RU, TR, ID, TW, IN)), - Device("Xiaomi 11i / Redmi K40 Pro / Pro+", "haydn", "KK", listOf(CN, GL, EEA, IN)), - Device("Redmi Note 10", "mojito", "KG", listOf(GL, ID, RU, IN, TR, EEA)), - Device("Redmi Note 10S / POCO M5s", "rosemary", "KL", listOf(GL, ID, RU, TR, EEA, TW)), - Device("Redmi Note 10 (Global) / Note 10T / POCO M3 Pro", "camellian", "KS", listOf(GL, ID, RU, TR, EEA, TW)), - Device("Redmi Note 10 Pro", "sweet", "KF", listOf(GL, ID, RU, TR, EEA, TW, ID)), - Device("Redmi Note 12 Pro 4G", "sweet", "HG", listOf(GL, ID, RU, TR, EEA, TW, ID)), - Device("Redmi Note 10 Pro (India) / Pro Max", "sweetin", "KF", listOf(IN)), - Device("Xiaomi 10S", "thyme", "GA", listOf(CN)), - Device("POCO X3 Pro", "vayu", "JU", listOf(GL, EEA, RU, TR, ID, TW)), - Device("Xiaomi 11 Lite 4G", "courbet", "KQ", listOf(GL, RU, EEA, IN, ID)), - Device("Xiaomi 11 Ultra / Pro", "star", "KA", listOf(CN, IN, EEA, GL, ID)), - Device("Xiaomi 11 Lite", "renoir", "KI", listOf(CN, EEA, GL, RU, JP, TW)), - Device("Xiaomi MIX Fold", "cetus", "JT", listOf(CN)), - Device("Redmi K40 Gaming / POCO F3 GT", "ares", "KJ", listOf(CN, IN)), - Device("Redmi Note 8 (2021)", "biloba", "CU", listOf(EEA, RU)), - Device("Redmi Note 10 / Note 11SE / Note 10T / POCO M3 Pro", "camellia", "KS", listOf(CN, IN)), - Device("Redmi Note 10 Pro (China) / POCO X3 GT", "chopin", "KP", listOf(CN, ID, TR, GL)), - Device("Xiaomi Pad 5", "nabu", "KX", listOf(CN, IN, TW, TR, EEA, RU, GL)), - Device("Xiaomi Pad 5 Pro WiFi", "elish", "KY", listOf(CN)), - Device("Xiaomi Pad 5 Pro", "enuma", "KZ", listOf(CN)), - Device("Xiaomi MIX 4", "odin", "KM", listOf(CN)), - Device("Redmi 10 / 10 Prime / Note 11 4G", "selene", "KU", listOf(CN, GL, EEA, RU, TR, ID, TW, IN)), - Device("Xiaomi 11T Pro", "vili", "KD", listOf(GL, EEA, RU, TR, ID, TW, IN, JP)), - Device("Xiaomi 11T", "agate", "KW", listOf(GL, EEA, RU, TR, ID, TW)), - Device("Xiaomi 11 LE / 11 Lite NE", "lisa", "KO", listOf(CN, GL, EEA, RU, TR, TW, IN)), - Device("Xiaomi Civi", "mona", "KV", listOf(CN)), - Device("Redmi Note 11 / Note 11T", "evergo", "GB", listOf(CN, IN)), - Device("Xiaomi 11i / Redmi Note 11 Pro / Note 11 Pro+", "pissarro", "GC", listOf(CN, RU, TW, TR, EEA, GL, IN)), - Device("POCO M4 Pro", "evergreen", "GB", listOf(GL, EEA, RU, TR, TW)), - Device("Xiaomi 12", "cupid", "LC", listOf(CN, GL, EEA, RU, TW, ID, TR)), - Device("Xiaomi 12X", "psyche", "LD", listOf(CN, GL, EEA, RU, TW)), - Device("Xiaomi 12 Pro", "zeus", "LB", listOf(CN, GL, IN, EEA, RU, TW, ID, TR)), - Device("Redmi Note 11S 4G / POCO M4 Pro 4G", "fleur", "KE", listOf(IN, GL, EEA, RU, TW, ID, TR)), - Device("Redmi Note 11S", "opal", "GL", listOf(EEA, GL, RU, TW)), - Device("Redmi Note 11E Pro / Note 11 Pro / POCO X4 Pro", "veux", "KC", listOf(CN, JP, EEA, RU, TW, IN, ID, TR)), - Device("Redmi Note 11", "spes", "GC", listOf(GL, IN, TR)), - Device("Redmi Note 11 NFC", "spesn", "GK", listOf(GL, EEA, RU, ID)), - Device("Redmi K50G / POCO F4 GT", "ingres", "LJ", listOf(CN, EEA, RU, TR, ID, TW)), - Device("Redmi 10 / 11 Prime / Note 11E / POCO M4", "light", "LS", listOf(CN, GL, IN, TR, EEA, RU, ID, TW)), - Device("Redmi Note 11R", "lightcm", "LS", listOf(CN)), - Device("Redmi Note 11 Pro 4G", "viva", "GD", listOf(GL, EEA, TW, ID, RU, TR)), - Device("Redmi K40S / POCO F4", "munch", "LM", listOf(CN, EEA, IN, ID, TW, TR, GL, RU)), - Device("Redmi K50 Pro", "matisse", "LK", listOf(CN)), - Device("Redmi K50", "rubens", "LN", listOf(CN)), - Device("Redmi 10C", "fog", "GE", listOf(GL, ID, EEA, IN, RU, TW, TR)), - Device("Redmi 9A / 9i / 9AT / 10A", "dandelion", "CD", listOf(CN, GL, EEA, IN, RU, TW, TR, ID)), - Device("Redmi Note 10T", "lilac", "KN", listOf(JP)), - Device("Xiaomi Civi 1S", "zijin", "LP", listOf(CN)), - Device("Redmi K50i / Note 11T Pro / POCO X4 GT", "xaga", "LO", listOf(CN, GL, EEA, RU, TW, IN, TR)), - Device("POCO C40", "frost", "GF", listOf(GL, EEA, RU, TW, TR)), - Device("Xiaomi 12 Lite", "taoyao", "LI", listOf(GL, EEA, RU, TW, ID, TR)), - Device("Xiaomi 12 Pro Dimensity", "daumier", "LG", listOf(CN)), - Device("Xiaomi 12S Pro", "unicorn", "LE", listOf(CN)), - Device("Xiaomi 12S", "mayfly", "LT", listOf(CN)), - Device("Xiaomi 12S Ultra", "thor", "LA", listOf(CN)), - Device("Xiaomi MIX Fold 2", "zizhan", "LR", listOf(CN)), - Device("Xiaomi 12T Pro / Redmi K50 Ultra", "diting", "LF", listOf(CN, GL, EEA, JP, TR, RU, TW)), - Device("Xiaomi Pad 5 Pro 12.4", "dagu", "LZ", listOf(CN)), - Device("Redmi 11 Prime 4G / POCO M5", "rock", "LU", listOf(GL, EEA, IN, TW, TR, ID, RU)), - Device("Redmi A1 / POCO C50", "ice", "GM", listOf(EEA, GL, IN, ID, RU, TW)), - Device("Xiaomi 13 Lite / Civi 2 ", "ziyi", "LL", listOf(CN, GL, EEA, RU, TW, TR)), - Device("Redmi Pad", "yunluo", "LY", listOf(CN, GL, IN, RU, TW, TR, EEA, ID)), - Device("Xiaomi 12T", "plato", "LQ", listOf(GL, ID, RU, TW, TR, EEA)), - Device("Redmi Note 12 Pro", "ruby", "MO", listOf(CN, GL, ID, RU, TW, IN, EEA)), - Device("Redmi Note 12 / Note 12R Pro", "sunstone", "MQ", listOf(CN, GL, TW, IN, EEA)), - Device("POCO X5", "moonstone", "MP", listOf(GL, TW, IN, ID, EEA, RU, TR)), - Device("Xiaomi 13", "fuxi", "MC", listOf(CN, GL, TW, EEA, RU, TR)), - Device("Xiaomi 13 Pro", "nuwa", "MB", listOf(CN, GL, TW, IN, EEA, RU, TR)), - Device("Redmi K60 / POCO F5 Pro", "mondrian", "MN", listOf(CN, GL, TW, EEA, RU, TR)), - Device("Redmi K60 Pro", "socrates", "MK", listOf(CN)), - Device("Redmi K60E", "rembrandt", "MM", listOf(CN)), - Device("Redmi Note 12 Pro Speed / POCO X5 Pro", "redwood", "MS", listOf(CN, EEA, ID, TW, TR, GL, IN, RU)), - Device("Redmi 12C / POCO C55", "earth", "CV", listOf(CN, GL, TW, IN, EEA, ID, RU, TR)), - Device("Redmi A2 / POCO C51", "water", "GO", listOf(GL, TW, EEA, IN, ID, RU)), - Device("Redmi Note 12 Turbo / POCO F5", "marble", "MR", listOf(CN, GL, TW, EEA, IN, ID, RU, TR)), - Device("Redmi Note 12 4G", "tapas", "MT", listOf(GL, IN, TR)), - Device("Redmi Note 12 4G NFC", "topaz", "MG", listOf(GL, EEA, ID, RU)), - Device("Xiaomi Pad 6", "pipa", "MZ", listOf(CN, GL, TW, EEA, IN, ID, RU, TR)), - Device("Xiaomi Pad 6 Pro", "liuqin", "MY", listOf(CN)), - Device("Xiaomi 13 Ultra", "ishtar", "MA", listOf(CN, GL, EEA, RU, TW)), - Device("Redmi Note 12S", "sea", "HZ", listOf(TR, GL, EEA, RU, TW)), - Device("Xiaomi Civi 3", "yuechu", "MI", listOf(CN)), - Device("Redmi Note 12T Pro", "pearl", "LH", listOf(CN)), - Device("Redmi 12", "fire", "MX", listOf(GL, EEA, IN, ID, RU, TR)), - Device("Redmi Note 12 / Note 12R / POCO M6 Pro", "sky", "MW", listOf(CN, EEA, GL, IN, TW)), - Device("Xiaomi Pad 6 Max 14", "yudi", "MH", listOf(CN)), - Device("Xiaomi 13T Pro / Redmi K60 Ultra", "corot", "ML", listOf(CN, EEA, GL, RU, TW, TR)), - Device("Xiaomi MIX Fold 3", "babylon", "MV", listOf(CN)), - Device("Redmi Pad SE", "xun", "MU", listOf(CN, EEA, GL, ID, RU, TW, TR)), - Device("Redmi Note 13 Pro+", "zircon", "NO", listOf(CN)), - Device("Redmi Note 13 / 13R Pro", "gold", "NQ", listOf(CN)), - Device("Redmi Note 13 Pro", "garnet", "NR", listOf(CN)), - Device("Xiaomi 13T", "aristotle", "MF", listOf(GL, EEA, ID, RU, TW, TR)), - Device("Xiaomi 14", "houji", "NC", listOf(CN)), - Device("Xiaomi 14 Pro", "shennong", "NB", listOf(CN)), - Device("Redmi 13C / POCO C65", "gale", "GP", listOf(GL, EEA, IN, TW)), - Device("Redmi K70 / POCO F6 Pro", "vermeer", "NK", listOf(CN)), - Device("Redmi K70 Pro", "manet", "NM", listOf(CN)), - Device("Redmi K70E / POCO X6 Pro", "duchamp", "NL", listOf(CN)), + Device("Redmi K30 4G", "phoenix", "GH"), + Device("POCO X2", "phoenixin", "GH"), + Device("Redmi K30 / K30i", "picasso", "GI"), + Device("Xiaomi 10", "umi", "JB"), + Device("Xiaomi 10 Pro", "cmi", "JA"), + Device("Redmi Note 9 Pro", "joyeuse", "JZ"), + Device("Redmi Note 9 Pro (India) / Note 9S / Note 10 Lite", "curtana", "JW"), + Device("Redmi Note 9 Pro Max", "excalibur", "JX"), + Device("Redmi K30 Pro", "lmi", "JK"), + Device("Xiaomi 10 Lite", "monet", "JI"), + Device("Xiaomi 10 Lite (China)", "vangogh", "JV"), + Device("Redmi Note 9 / 10X 4G", "merlin", "JO"), + Device("Redmi 10X", "atom", "JH"), + Device("Redmi 10X Pro", "bomb", "JL"), + Device("Xiaomi Note 10 Lite ", "toco", "FN"), + Device("Redmi 9 / 9 Prime", "lancelot", "JC"), + Device("POCO M2 Pro", "gram", "JP"), + Device("Redmi K30 Ultra", "cezanne", "JN"), + Device("Xiaomi 10 Ultra", "cas", "JJ"), + Device("POCO X3 NFC", "surya", "JG"), + Device("Xiaomi 10T / 10T Pro / Redmi K30S Ultra", "apollo", "JD"), + Device("POCO M3", "citrus", "JF"), + Device("Redmi 9T / 9 Power / Note 9 4G", "lime", "JQ"), + Device("Redmi Note 9", "cannon", "JE"), + Device("Xiaomi 10T Lite / 10i / Redmi Note 9 Pro", "gauguin", "JS"), + Device("Redmi Note 9T", "cannong", "JE"), + Device("Xiaomi 11", "venus", "KB"), + Device("Redmi K40 / POCO F3", "alioth", "KH"), + Device("Xiaomi 11i / Redmi K40 Pro / Pro+", "haydn", "KK"), + Device("Redmi Note 10", "mojito", "KG"), + Device("Redmi Note 10S / POCO M5s", "rosemary", "KL"), + Device("Redmi Note 10 (Global) / Note 10T / POCO M3 Pro", "camellian", "KS"), + Device("Redmi Note 10 Pro", "sweet", "KF"), + Device("Redmi Note 12 Pro 4G", "sweet", "HG"), + Device("Redmi Note 10 Pro (India) / Pro Max", "sweetin", "KF"), + Device("Xiaomi 10S", "thyme", "GA"), + Device("POCO X3 Pro", "vayu", "JU"), + Device("Xiaomi 11 Lite 4G", "courbet", "KQ"), + Device("Xiaomi 11 Ultra / Pro", "star", "KA"), + Device("Xiaomi 11 Lite", "renoir", "KI"), + Device("Xiaomi MIX Fold", "cetus", "JT"), + Device("Redmi K40 Gaming / POCO F3 GT", "ares", "KJ"), + Device("Redmi Note 8 (2021)", "biloba", "CU"), + Device("Redmi Note 10 / Note 11SE / Note 10T / POCO M3 Pro", "camellia", "KS"), + Device("Redmi Note 10 Pro (China) / POCO X3 GT", "chopin", "KP"), + Device("Xiaomi Pad 5", "nabu", "KX"), + Device("Xiaomi Pad 5 Pro WiFi", "elish", "KY"), + Device("Xiaomi Pad 5 Pro", "enuma", "KZ"), + Device("Xiaomi MIX 4", "odin", "KM"), + Device("Redmi 10 / 10 Prime / Note 11 4G", "selene", "KU"), + Device("Xiaomi 11T Pro", "vili", "KD"), + Device("Xiaomi 11T", "agate", "KW"), + Device("Xiaomi 11 LE / 11 Lite NE", "lisa", "KO"), + Device("Xiaomi Civi", "mona", "KV"), + Device("Redmi Note 11 / Note 11T", "evergo", "GB"), + Device("Xiaomi 11i / Redmi Note 11 Pro / Note 11 Pro+", "pissarro", "GC"), + Device("POCO M4 Pro", "evergreen", "GB"), + Device("Xiaomi 12", "cupid", "LC"), + Device("Xiaomi 12X", "psyche", "LD"), + Device("Xiaomi 12 Pro", "zeus", "LB"), + Device("Redmi Note 11S 4G / POCO M4 Pro 4G", "fleur", "KE"), + Device("Redmi Note 11S", "opal", "GL"), + Device("Redmi Note 11E Pro / Note 11 Pro / POCO X4 Pro", "veux", "KC"), + Device("Redmi Note 11", "spes", "GC"), + Device("Redmi Note 11 NFC", "spesn", "GK"), + Device("Redmi K50G / POCO F4 GT", "ingres", "LJ"), + Device("Redmi 10 / 11 Prime / Note 11E / POCO M4", "light", "LS"), + Device("Redmi Note 11R", "lightcm", "LS"), + Device("Redmi Note 11 Pro 4G", "viva", "GD"), + Device("Redmi K40S / POCO F4", "munch", "LM"), + Device("Redmi K50 Pro", "matisse", "LK"), + Device("Redmi K50", "rubens", "LN"), + Device("Redmi 10C", "fog", "GE"), + Device("Redmi 9A / 9i / 9AT / 10A", "dandelion", "CD"), + Device("Redmi Note 10T", "lilac", "KN"), + Device("Xiaomi Civi 1S", "zijin", "LP"), + Device("Redmi K50i / Note 11T Pro / POCO X4 GT", "xaga", "LO"), + Device("POCO C40", "frost", "GF"), + Device("Xiaomi 12 Lite", "taoyao", "LI"), + Device("Xiaomi 12 Pro Dimensity", "daumier", "LG"), + Device("Xiaomi 12S Pro", "unicorn", "LE"), + Device("Xiaomi 12S", "mayfly", "LT"), + Device("Xiaomi 12S Ultra", "thor", "LA"), + Device("Xiaomi MIX Fold 2", "zizhan", "LR"), + Device("Xiaomi 12T Pro / Redmi K50 Ultra", "diting", "LF"), + Device("Xiaomi Pad 5 Pro 12.4", "dagu", "LZ"), + Device("Redmi 11 Prime 4G / POCO M5", "rock", "LU"), + Device("Redmi A1 / POCO C50", "ice", "GM"), + Device("Xiaomi 13 Lite / Civi 2 ", "ziyi", "LL"), + Device("Redmi Pad", "yunluo", "LY"), + Device("Xiaomi 12T", "plato", "LQ"), + Device("Redmi Note 12 Pro", "ruby", "MO"), + Device("Redmi Note 12 / Note 12R Pro", "sunstone", "MQ"), + Device("POCO X5", "moonstone", "MP"), + Device("Xiaomi 13", "fuxi", "MC"), + Device("Xiaomi 13 Pro", "nuwa", "MB"), + Device("Redmi K60 / POCO F5 Pro", "mondrian", "MN"), + Device("Redmi K60 Pro", "socrates", "MK"), + Device("Redmi K60E", "rembrandt", "MM"), + Device("Redmi Note 12 Pro Speed / POCO X5 Pro", "redwood", "MS"), + Device("Redmi 12C / POCO C55", "earth", "CV"), + Device("Redmi A2 / POCO C51", "water", "GO"), + Device("Redmi Note 12 Turbo / POCO F5", "marble", "MR"), + Device("Redmi Note 12 4G", "tapas", "MT"), + Device("Redmi Note 12 4G NFC", "topaz", "MG"), + Device("Xiaomi Pad 6", "pipa", "MZ"), + Device("Xiaomi Pad 6 Pro", "liuqin", "MY"), + Device("Xiaomi 13 Ultra", "ishtar", "MA"), + Device("Redmi Note 12S", "sea", "HZ"), + Device("Xiaomi Civi 3", "yuechu", "MI"), + Device("Redmi Note 12T Pro", "pearl", "LH"), + Device("Redmi 12", "fire", "MX"), + Device("Redmi Note 12 / Note 12R / POCO M6 Pro", "sky", "MW"), + Device("Xiaomi Pad 6 Max 14", "yudi", "MH"), + Device("Xiaomi 13T Pro / Redmi K60 Ultra", "corot", "ML"), + Device("Xiaomi MIX Fold 3", "babylon", "MV"), + Device("Redmi Pad SE", "xun", "MU"), + Device("Redmi Note 13 Pro+", "zircon", "NO"), + Device("Redmi Note 13 / 13R Pro", "gold", "NQ"), + Device("Redmi Note 13 Pro", "garnet", "NR"), + Device("Xiaomi 13T", "aristotle", "MF"), + Device("Xiaomi 14", "houji", "NC"), + Device("Xiaomi 14 Pro", "shennong", "NB"), + Device("Redmi 13C / POCO C65", "gale", "GP"), + Device("Redmi K70 / POCO F6 Pro", "vermeer", "NK"), + Device("Redmi K70 Pro", "manet", "NM"), + Device("Redmi K70E / POCO X6 Pro", "duchamp", "NL"), ) val deviceNames = devices.map { it.deviceName } val codeNames = devices.map { it.codeName } + val regionCodes = regionCode.map { it.regionCode } + + val androidVersion = androids.map { it.version } fun codeName(deviceName: String): String? { val device = devices.find { it.deviceName == deviceName } ?: return null @@ -172,15 +178,9 @@ object DeviceInfoHelper { return device.deviceName } - fun regions(codeName: String, regions: String): String { - val device = devices.find { it.codeName == codeName } ?: return "" - val newRegions = device.regionCode.find { it.version == regions } ?: return "" - return newRegions.codeNameExt - } - - fun existRegions(codeName: String): List { - val device = devices.find { it.codeName == codeName } ?: return emptyList() - return device.regionCode.map { it.version } + fun regionCodeNameExt(regions: String): String { + val regionCode = regionCode.find { it.regionCode == regions } ?: return "" + return regionCode.codeNameExt } fun deviceCode(android: String, codeName: String, variant: String): String { diff --git a/app/src/main/java/top/yukonga/update/logic/utils/AppUtils.kt b/app/src/main/java/top/yukonga/update/logic/utils/AppUtils.kt index 8e8fc8d3..dd30da95 100644 --- a/app/src/main/java/top/yukonga/update/logic/utils/AppUtils.kt +++ b/app/src/main/java/top/yukonga/update/logic/utils/AppUtils.kt @@ -19,8 +19,4 @@ object AppUtils { fun getProp(mKey: String, defaultValue: Boolean): Boolean = Class.forName("android.os.SystemProperties").getMethod("getBoolean", String::class.java, Boolean::class.javaPrimitiveType) .invoke(Class.forName("android.os.SystemProperties"), mKey, defaultValue) as Boolean - - val androidDropDownList = arrayOf("14", "13", "12", "11") - - val regionsDropDownList = arrayOf("CN", "GL", "EEA", "RU", "TW", "ID", "TR", "JP", "IN") } \ No newline at end of file diff --git a/app/src/main/java/top/yukonga/update/ui/MainActivity.kt b/app/src/main/java/top/yukonga/update/ui/MainActivity.kt index 1ff1db6f..c6519ef5 100644 --- a/app/src/main/java/top/yukonga/update/ui/MainActivity.kt +++ b/app/src/main/java/top/yukonga/update/ui/MainActivity.kt @@ -43,9 +43,7 @@ import top.yukonga.update.logic.data.RecoveryRomInfoHelper import top.yukonga.update.logic.fadInAnimation import top.yukonga.update.logic.fadOutAnimation import top.yukonga.update.logic.setTextAnimation -import top.yukonga.update.logic.utils.AppUtils.androidDropDownList import top.yukonga.update.logic.utils.AppUtils.dp -import top.yukonga.update.logic.utils.AppUtils.regionsDropDownList import top.yukonga.update.logic.utils.FileUtils import top.yukonga.update.logic.utils.FileUtils.downloadFile import top.yukonga.update.logic.utils.InfoUtils @@ -99,10 +97,13 @@ class MainActivity : AppCompatActivity() { // Setup DropDownList. val deviceNamesAdapter = CustomArrayAdapter(this@MainActivity, android.R.layout.simple_dropdown_item_1line, DeviceInfoHelper.deviceNames) val codeNamesAdapter = ArrayAdapter(this@MainActivity, android.R.layout.simple_dropdown_item_1line, DeviceInfoHelper.codeNames) + + val deviceRegionsAdapter = ArrayAdapter(this@MainActivity, android.R.layout.simple_dropdown_item_1line, DeviceInfoHelper.regionCodes) + val androidVersionAdapter = ArrayAdapter(this@MainActivity, android.R.layout.simple_dropdown_item_1line, DeviceInfoHelper.androidVersion) (deviceName.editText as? MaterialAutoCompleteTextView)?.setAdapter(deviceNamesAdapter) (codeName.editText as? MaterialAutoCompleteTextView)?.setAdapter(codeNamesAdapter) - (deviceRegions.editText as? MaterialAutoCompleteTextView)?.setSimpleItems(regionsDropDownList) - (androidVersion.editText as? MaterialAutoCompleteTextView)?.setSimpleItems(androidDropDownList) + (deviceRegions.editText as? MaterialAutoCompleteTextView)?.setAdapter(deviceRegionsAdapter) + (androidVersion.editText as? MaterialAutoCompleteTextView)?.setAdapter(androidVersionAdapter) // Setup TextChangedListener. codeNameWatcher = object : TextWatcher { @@ -115,10 +116,7 @@ class MainActivity : AppCompatActivity() { } if (text != null) { deviceName.editText!!.setText(text) - val existRegions = DeviceInfoHelper.existRegions(DeviceInfoHelper.codeName(text)!!) - val deviceRegionsAdapter = ArrayAdapter(this@MainActivity, android.R.layout.simple_dropdown_item_1line, existRegions) - (deviceRegions.editText as? MaterialAutoCompleteTextView)?.setAdapter(deviceRegionsAdapter) - } else (deviceRegions.editText as? MaterialAutoCompleteTextView)?.setSimpleItems(regionsDropDownList) + } } override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} @@ -136,10 +134,7 @@ class MainActivity : AppCompatActivity() { } if (text != null) { codeName.editText!!.setText(text) - val existRegions = DeviceInfoHelper.existRegions(text) - val deviceRegionsAdapter = ArrayAdapter(this@MainActivity, android.R.layout.simple_dropdown_item_1line, existRegions) - (deviceRegions.editText as? MaterialAutoCompleteTextView)?.setAdapter(deviceRegionsAdapter) - } else (deviceRegions.editText as? MaterialAutoCompleteTextView)?.setSimpleItems(regionsDropDownList) + } } override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {} @@ -230,7 +225,7 @@ class MainActivity : AppCompatActivity() { val codeNameText = codeName.editText?.text.toString() val deviceNameText = deviceName.editText?.text.toString() - val codeNameTextExtR = codeNameText + DeviceInfoHelper.regions(codeNameText, regionsText) + val codeNameTextExtR = codeNameText + DeviceInfoHelper.regionCodeNameExt(regionsText) val androidVersionText = androidVersion.editText?.text.toString() val systemVersionText = systemVersion.editText?.text.toString() @@ -239,22 +234,13 @@ class MainActivity : AppCompatActivity() { // Acquire ROM info. val recoveryRomInfo = InfoUtils.getRecoveryRomInfo( - this@MainActivity, - codeNameTextExtR, - regionsText, - systemVersionTextExt, - androidVersionText + this@MainActivity, codeNameTextExtR, regionsText, systemVersionTextExt, androidVersionText ).parseJSON() // val fastbootRomInfo = InfoUtils.getFastbootRomInfo(codeNameTextExtR).parseJSON() - prefs.edit() - .putString("deviceName", deviceNameText) - .putString("codeName", codeNameText) - .putString("regions", regionsText) - .putString("systemVersion", systemVersionText) - .putString("androidVersion", androidVersionText) - .apply() + prefs.edit().putString("deviceName", deviceNameText).putString("codeName", codeNameText).putString("regions", regionsText) + .putString("systemVersion", systemVersionText).putString("androidVersion", androidVersionText).apply() withContext(Dispatchers.Main) {