Skip to content

Commit fa230f3

Browse files
committed
fix: keep a failed database write from closing the app
MainViewModel launched every action straight in viewModelScope, which has no exception handler, so a write that threw (a full disk, a broken table) from a tap took the process down. Every action's launch now takes one handler that logs and shows a "Something went wrong" toast. Startup housekeeping logs only, since the user didn't tap anything. sync() had only try/finally, so a throw there would have left the state at Syncing with the Sync button disabled until a restart. It now ends as an error. New ViewModelActionFailureTest drops the tables under a block, an allow, a rule add and a rule restore and expects the toast for each; it fails with the handler removed. A closed database isn't used: Room 2.8 cancels its scope on close, so the write ends in a CancellationException.
1 parent 02badfe commit fa230f3

5 files changed

Lines changed: 238 additions & 112 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ All notable changes to CallShield will be documented in this file.
3838
- A block decision waits at most a quarter second for its call-log entry to be saved, then blocks the call and saves the entry after. When another database write was running, like a sync, that wait could push the block past Android's five-second limit, and the call rang.
3939
- The app now refuses the community watch list if it's served in place of the trending numbers feed. Both are signed and both list numbers, so a mirror could have passed one off as the other, turning numbers with a single report into blocked ones.
4040
- A failed link check on an RCS or chat message can no longer crash the app.
41+
- A database or storage error during a tap (a block, an allow, a rule, a setting) no longer closes the app. You get a "Something went wrong" message and can try again.
4142
- The community report merge counts one phone once a day per number, whichever spam type it picks. Picking a different type each time let one phone count up to nine times a day toward the trending list. A not-spam report still counts on its own. Reports of one number that land within a minute of each other are folded together the same way, by spam or not spam instead of by type.
4243
- The Chinese translation's regex example in the wildcard dialog showed with its backslashes missing.
4344
- Setup now spots a copy installed by an app store or installer that doesn't let Android allow SMS and call logs. Android never asks about those on such a copy, and their switches in App info flip back to Deny with no reason given. Once you've tried them, setup names the installer and offers Get the APK, which opens the latest release so you can install it over your copy from the Files app. Your settings stay. The README's troubleshooting section now covers this block next to restricted settings.

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<p align="center">
1313
<a href="https://github.com/SysAdminDoc/CallShield/releases/latest"><img src="https://img.shields.io/github/v/release/SysAdminDoc/CallShield?style=flat-square&color=a6e3a1" alt="Release"></a>
1414
<img src="https://img.shields.io/badge/Spam%20Numbers-51%2C379-f38ba8?style=flat-square" alt="51,379 Numbers">
15-
<img src="https://img.shields.io/badge/JVM%20unit%20tests-2006-94e2d5?style=flat-square" alt="2006 JVM unit tests">
15+
<img src="https://img.shields.io/badge/JVM%20unit%20tests-2008-94e2d5?style=flat-square" alt="2008 JVM unit tests">
1616
<img src="https://img.shields.io/badge/Android-10%2B-89b4fa?style=flat-square" alt="Android 10+">
1717
<img src="https://img.shields.io/badge/License-MIT-cba6f7?style=flat-square" alt="MIT License">
1818
<img src="https://img.shields.io/badge/API%20Keys-None-fab387?style=flat-square" alt="No required API keys">
@@ -592,12 +592,12 @@ RELEASE_KEY_PASSWORD=...
592592
## Testing
593593

594594
```bash
595-
./gradlew testDebugUnitTest # 2006 tests
595+
./gradlew testDebugUnitTest # 2008 tests
596596
./gradlew connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.sysadmindoc.callshield.platform.TargetSdkBehaviorSmokeTest
597597
./gradlew verifyPipelineTests # Cloudflare Worker (node) + data-pipeline and translation checks (python)
598598
```
599599

600-
The suite is **2006 total JVM unit tests**, run with Robolectric wherever a screen, a service or the database is involved.
600+
The suite is **2008 total JVM unit tests**, run with Robolectric wherever a screen, a service or the database is involved.
601601

602602
Two GitHub workflows run without building the app. **Validation** runs the Worker and
603603
pipeline suites on every push except report-only ones (`run-pipeline-tests.ps1 -CorrectnessOnly`),
@@ -634,8 +634,8 @@ language in [issue #7](https://github.com/SysAdminDoc/CallShield/issues/7).
634634
| Community API | Cloudflare Workers |
635635
| URL Safety | Local spam-domain data, with optional PhishTank and OpenPhish |
636636
| Verification | Local Gradle, lint, and release-artifact checks |
637-
| Tests | 2006 JVM unit tests (JUnit) |
638-
| Strings | 1792 string resources and 49 plural groups (translation-ready) |
637+
| Tests | 2008 JVM unit tests (JUnit) |
638+
| Strings | 1793 string resources and 49 plural groups (translation-ready) |
639639
| Accessibility | 100+ content descriptions, 48dp touch targets |
640640
| Min SDK | 29 (Android 10) |
641641
| Target SDK | 36 |

0 commit comments

Comments
 (0)