Fix ss2022 import for old base64 format

Old format has userinfo = null, will throw NPE
This commit is contained in:
yuhan6665
2022-06-24 23:41:21 -04:00
parent 1822613985
commit e23e9c48a4

View File

@@ -3,8 +3,9 @@ package com.v2ray.ang.util
import android.content.Context
import android.content.SharedPreferences
import android.graphics.Bitmap
import androidx.preference.PreferenceManager
import android.text.TextUtils
import android.util.Log
import androidx.preference.PreferenceManager
import com.google.gson.Gson
import com.tencent.mmkv.MMKV
import com.v2ray.ang.AppConfig
@@ -396,6 +397,7 @@ object AngConfigManager {
}
private fun tryResolveResolveSip002(str: String, config: ServerConfig): Boolean {
try {
val uri = URI(str.replace(" ", "%20"))
config.remarks = Utils.urlDecode(uri.fragment ?: "")
@@ -411,7 +413,7 @@ object AngConfigManager {
} else {
val base64Decode = Utils.decode(uri.userInfo)
val arrUserInfo = base64Decode.split(":").map { it.trim() }
if (arrUserInfo.count() != 2 && arrUserInfo.count() != 3) {
if (arrUserInfo.count() < 2) {
return false
}
method = arrUserInfo[0]
@@ -425,6 +427,10 @@ object AngConfigManager {
server.method = method
}
return true
} catch (e: Exception) {
Log.d(AppConfig.ANG_PACKAGE, e.toString())
return false
}
}
/**