Complete removal of deprecated fields and methods:
- Remove userApiToken and deviceId from TrmnlDeviceConfig
- Remove deprecated DataStore methods (saveUserApiToken, getUserApiToken, saveDeviceId, getDeviceId)
- Remove userApiToken from AppSettingsScreen state and UI
- Remove USER_API_TOKEN_KEY and DEVICE_ID_KEY constants
- Add context comments for battery percentage reporting
This simplifies the codebase by fully removing unused code paths rather
than keeping them as deprecated.
Replace complex user-level battery reporting (PATCH /api/devices/{id}) with
simplified device-level Percent-Charged header sent with image fetch requests.
Changes:
- Add percentCharged parameter to TrmnlApiService.getNextDisplayData()
- Update TrmnlDisplayRepository to send battery for BYOD devices only
- Deprecate reportDeviceBatteryStatus() and getDeviceIdFromApi() methods
- Remove battery reporting call from TrmnlImageRefreshWorker
- Disable user API token UI in AppSettingsScreen (100+ lines)
- Deprecate TrmnlUserApiService and TrmnlDeviceUpdateRequest
- Deprecate userApiToken and deviceId in TrmnlDeviceConfig
- Deprecate DataStore methods for user token and device ID
- Add 4 new battery percentage header tests
- Ignore 6 deprecated battery/device ID tests
- Update existing RSSI tests to include percentCharged parameter
Benefits:
- Simpler: No separate API call needed
- Secure: Uses device-level auth only (no user token required)
- Consistent: Follows same pattern as RSSI header
- BYOD-only: Battery reporting limited to BYOD devices as designed
All changes maintain backward compatibility with deprecated code preserved.
Verified with:
- formatKotlin: ✅ (0 errors)
- lintKotlin: ✅ (0 errors)
- testDebugUnitTest: ✅ (203 passed, 9 skipped)
- assembleDebug: ✅ (APK built successfully)
- Add AndroidDeviceInfoProviderTest.kt with 14 unit tests
* Tests for getWifiSignalStrength() method covering:
- Valid RSSI values (strong, medium, weak signals)
- Null handling (WiFi manager unavailable, connection info null, RSSI -127)
- Exception handling
* Tests for getBatteryLevel() method covering:
- Valid battery percentages (0%, 85%, 100%)
- Null handling (battery manager unavailable)
- Exception handling
- Add 8 integration tests to TrmnlDisplayRepositoryTest.kt
* Verify RSSI is sent only for BYOD devices
* Verify RSSI is NOT sent for TRMNL and BYOS devices
* Test RSSI with various signal strengths (-30, -65, -90 dBm)
* Test null RSSI handling when WiFi unavailable
* Verify getWifiSignalStrength() is called only for BYOD
Total: 22 new tests added (199 tests total, up from 178)
All tests passing with no failures.
- Add getWifiSignalStrength() method to AndroidDeviceInfoProvider to retrieve WiFi RSSI in dBm
- Add RSSI header parameter to TrmnlApiService.getNextDisplayData() API call
- Update TrmnlDisplayRepository to fetch and send WiFi signal strength to TRMNL API for BYOD devices
- Add ACCESS_WIFI_STATE permission to AndroidManifest.xml
- RSSI values match firmware implementation (dBm scale, -100 to 0)
- Only sends RSSI for BYOD device type to match firmware behavior
This enables the TRMNL API to receive WiFi signal strength data from Android
devices for monitoring and diagnostics, matching the functionality of the
TRMNL firmware devices.
Complete the domain migration by updating the remaining 7 references:
- README.md: Related references links
- TrmnlUserApiService.kt: Example URL in updateDevice docs
- google_play_description.txt: Learn more link and changelog
- project-resources/google-play/google_play_description.txt: Same updates
All usetrmnl.com references have now been migrated to trmnl.com
Related to #240
Update base domain from usetrmnl.com to trmnl.com across the entire
codebase including:
- API base URLs (TRMNL_API_SERVER_BASE_URL, TRMNL_SITE_URL)
- Documentation links (docs.usetrmnl.com → docs.trmnl.com)
- Help articles (help.usetrmnl.com → help.trmnl.com)
- Code comments and examples
- Test data
- README and Google Play Store descriptions
This aligns with TRMNL's domain migration as documented in:
https://trmnl.com/blog/trmnl-dot-comFixes#240
The device ID was being fetched and saved to DataStore during BYOD
device validation, but it wasn't included in the TrmnlDeviceConfig
object when saving the full configuration. This caused the device ID
to be null in the loaded config, resulting in battery reporting being
skipped with 'device ID is null' warnings.
Now we retrieve the device ID from DataStore before saving the full
config and include it in the TrmnlDeviceConfig object for BYOD devices.
- Create AndroidDeviceInfoProvider class for device info operations
- Inject AndroidDeviceInfoProvider into TrmnlDisplayRepository
- Remove inline battery reporting from getNextDisplayData/getCurrentDisplayData
- Add reportDeviceBatteryStatus() as public API for battery reporting
- Make reportBatteryStatus() private (internal implementation)
- Update TrmnlImageRefreshWorker to call reportDeviceBatteryStatus after successful refresh
- Remove Context dependency from TrmnlDisplayRepository
- Update tests to reflect new architecture
- Add comprehensive tests for reportDeviceBatteryStatus
This refactoring improves separation of concerns and makes the code
more maintainable and testable.
- Add tests for getDeviceIdFromApi() method (mocked response)
- Add tests for reportBatteryStatus() success and failure scenarios
- Add tests for null deviceId and userApiToken validation
- Add tests for fake data mode behavior
- Add tests for saveDeviceId/getDeviceId in TrmnlDeviceConfigDataStore
- Add tests for deviceId persistence in dual-storage (JSON + legacy)
- Add tests for deviceId removal when set to null
Test coverage includes:
- 6 new tests in TrmnlDisplayRepositoryTest
- 5 new tests in TrmnlDeviceConfigDataStoreTest
- All edge cases and error conditions validated
- Add /api/devices/me endpoint to TrmnlApiService for device info retrieval
- Add deviceId field to TrmnlDeviceConfig model with documentation
- Extend TrmnlDeviceConfigDataStore with deviceId persistence (dual-storage)
- Add getDeviceIdFromApi() to repository (mocked until server endpoint exists)
- Add getBatteryLevel() and reportBatteryStatus() for battery management
- Integrate battery reporting in display fetch methods (non-blocking)
- Update AppSettingsScreen to fetch deviceId during BYOD validation
- Update TrmnlDisplayRepositoryTest with Context mock dependency
Battery reporting is BYOD-only, requires deviceId and userApiToken.
Runs asynchronously after successful display fetches without blocking UI.
- Add String?.obfuscated() extension function for secure logging
- Replace all instances of `take(8)?.plus("...") ?: "null"` pattern
- Improves code maintainability and reduces duplication
- Consistent token logging across all DataStore operations