From 73929f08e9076009b83af027e8064fe536bc79b0 Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 4 Nov 2020 07:58:33 +0800 Subject: [PATCH] Prevent crash if SECURITY_PATCH cannot be recognized --- mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt index ea4dc5f5..f82a3cf8 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt @@ -57,8 +57,8 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene @delegate:TargetApi(29) private val hasP2pValidateName by lazy { - val (y, m, _) = Build.VERSION.SECURITY_PATCH.split('-', limit = 3).map { it.toInt() } - y > 2020 || y == 2020 && m >= 3 + val (y, m, _) = Build.VERSION.SECURITY_PATCH.split('-', limit = 3).map { it.toIntOrNull() } + y == null || y > 2020 || y == 2020 && (m == null || m >= 3) } val safeModeConfigurable get() = Build.VERSION.SDK_INT >= 29 && hasP2pValidateName val safeMode get() = Build.VERSION.SDK_INT >= 29 &&