Compare commits

..

2 commits

3 changed files with 21 additions and 21 deletions

View file

@ -164,14 +164,14 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
}
private fun operationToLocalizedText(operation: ProfileManagementOperation) =
root.context.getText(
when (operation) {
ProfileManagementOperation.Install -> R.string.profile_notification_operation_download
ProfileManagementOperation.Delete -> R.string.profile_notification_operation_delete
ProfileManagementOperation.Enable -> R.string.profile_notification_operation_enable
ProfileManagementOperation.Disable -> R.string.profile_notification_operation_disable
})
private fun operationToLocalizedText(operation: ProfileManagementOperation?) =
root.context.getString(when (operation) {
ProfileManagementOperation.Install -> R.string.profile_notification_operation_download
ProfileManagementOperation.Delete -> R.string.profile_notification_operation_delete
ProfileManagementOperation.Enable -> R.string.profile_notification_operation_enable
ProfileManagementOperation.Disable -> R.string.profile_notification_operation_disable
else -> throw IllegalStateException("Unknown operation: $operation")
})
fun updateNotification(value: LocalProfileNotificationWrapper) {
notification = value

View file

@ -9,21 +9,21 @@ private val invalidDPAddresses = setOf(
"testrootsmds.example.com",
)
class EuiccConfiguredAddresses(defaultDPAddress: String, rootDSAddress: String) {
val defaultDPAddress = defaultDPAddress.takeUnless(::isInvalidDPAddress)
val rootDSAddress = rootDSAddress.takeUnless(::isInvalidDSAddress)
data class EuiccConfiguredAddresses(
val defaultDPAddress: String,
val rootDSAddress: String
) {
val discoverable: Boolean
get() = !defaultDPAddress.isNullOrBlank() || !rootDSAddress.isNullOrBlank()
get() = isValidDPAddress(defaultDPAddress) ||
isValidDSAddress(rootDSAddress)
}
private fun isInvalidDPAddress(address: String?): Boolean {
if (address.isNullOrBlank()) return true
return !Patterns.DOMAIN_NAME.matcher(address).matches()
private fun isValidDPAddress(address: String): Boolean {
return address.isNotBlank() && Patterns.DOMAIN_NAME.matcher(address).matches()
}
private fun isInvalidDSAddress(address: String?): Boolean {
if (address.isNullOrBlank()) return true
if (address in invalidDPAddresses) return true
return !Patterns.DOMAIN_NAME.matcher(address).matches()
private fun isValidDSAddress(address: String): Boolean {
if (address.isBlank()) return false
if (address in invalidDPAddresses) return false
return Patterns.DOMAIN_NAME.matcher(address).matches()
}

View file

@ -2,7 +2,7 @@ package net.typeblog.lpac_jni
data class LocalProfileNotification(
val seqNumber: Long,
val profileManagementOperation: ProfileManagementOperation,
val profileManagementOperation: ProfileManagementOperation?,
val notificationAddress: String,
val iccid: String,
)