Compare commits
1 commit
bb5417d37f
...
15b9a90db0
Author | SHA1 | Date | |
---|---|---|---|
15b9a90db0 |
2 changed files with 10 additions and 9 deletions
|
@ -126,7 +126,7 @@ class DownloadWizardMethodSelectFragment : DownloadWizardActivity.DownloadWizard
|
||||||
state.matchingId = parsed.matchingId
|
state.matchingId = parsed.matchingId
|
||||||
state.confirmationCodeRequired = parsed.confirmationCodeRequired
|
state.confirmationCodeRequired = parsed.confirmationCodeRequired
|
||||||
gotoNextFragment(DownloadWizardDetailsFragment())
|
gotoNextFragment(DownloadWizardDetailsFragment())
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalStateException) {
|
||||||
AlertDialog.Builder(requireContext()).apply {
|
AlertDialog.Builder(requireContext()).apply {
|
||||||
setTitle(R.string.profile_download_incorrect_lpa_string)
|
setTitle(R.string.profile_download_incorrect_lpa_string)
|
||||||
setMessage(R.string.profile_download_incorrect_lpa_string_message)
|
setMessage(R.string.profile_download_incorrect_lpa_string_message)
|
||||||
|
|
|
@ -8,15 +8,16 @@ data class LPAString(
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
fun parse(input: String): LPAString {
|
fun parse(input: String): LPAString {
|
||||||
val components = input.removePrefix("LPA:").split('$')
|
var token = input
|
||||||
if (components.size < 2 || components[0] != "1") {
|
if (token.startsWith("LPA:", true)) token = token.drop(4)
|
||||||
throw IllegalArgumentException("Invalid activation code format")
|
val components = token.split('$').map { it.trim().ifBlank { null } }
|
||||||
}
|
check(components.size > 1) { "Invalid activation code format" }
|
||||||
|
check(components[0] == "1") { "Invalid AC_Format" }
|
||||||
return LPAString(
|
return LPAString(
|
||||||
address = components[1].trim(),
|
checkNotNull(components[1]) { "SM-DP+ is required" },
|
||||||
matchingId = components.getOrNull(2)?.trim()?.ifBlank { null },
|
components.getOrNull(2),
|
||||||
oid = components.getOrNull(3)?.trim()?.ifBlank { null },
|
components.getOrNull(3),
|
||||||
confirmationCodeRequired = components.getOrNull(4)?.trim() == "1"
|
components.getOrNull(4) == "1"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue