Skip to content

Commit ce5b357

Browse files
authored
fix: ensure valid column index (#462)
* fix: ensure valid column index See: #461 * refactor: use extension from commons * docs: update changelog
1 parent fb7a394 commit ce5b357

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixed inability to view messages when there is no SIM card ([#461])
13+
1014
## [1.2.1] - 2025-06-17
1115

1216
### Changed
@@ -171,3 +175,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
171175
[#279]: https://github.com/FossifyOrg/Messages/issues/279
172176
[#287]: https://github.com/FossifyOrg/Messages/issues/287
173177
[#294]: https://github.com/FossifyOrg/Messages/issues/294
178+
[#461]: https://github.com/FossifyOrg/Messages/issues/461

app/src/main/kotlin/org/fossify/messages/extensions/Context.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import me.leolin.shortcutbadger.ShortcutBadger
3030
import org.fossify.commons.extensions.areDigitsOnly
3131
import org.fossify.commons.extensions.getBlockedNumbers
3232
import org.fossify.commons.extensions.getIntValue
33+
import org.fossify.commons.extensions.getIntValueOr
3334
import org.fossify.commons.extensions.getLongValue
3435
import org.fossify.commons.extensions.getMyContactsCursor
3536
import org.fossify.commons.extensions.getStringValue
@@ -161,7 +162,11 @@ fun Context.getMessages(
161162
val date = (cursor.getLongValue(Sms.DATE) / 1000).toInt()
162163
val read = cursor.getIntValue(Sms.READ) == 1
163164
val thread = cursor.getLongValue(Sms.THREAD_ID)
164-
val subscriptionId = cursor.getIntValue(Sms.SUBSCRIPTION_ID)
165+
val subscriptionId = cursor.getIntValueOr(
166+
key = Sms.SUBSCRIPTION_ID,
167+
defaultValue = SubscriptionManager.INVALID_SUBSCRIPTION_ID
168+
)
169+
165170
val status = cursor.getIntValue(Sms.STATUS)
166171
val participants = senderNumber.split(ADDRESS_SEPARATOR).map { number ->
167172
val phoneNumber = PhoneNumber(number, 0, "", number)

0 commit comments

Comments
 (0)