Commit Graph
619 Commits
Author SHA1 Message Date
Hossain Khan b0958b8564 refactor: remove deprecated user token and device ID code
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.
2026-02-05 19:54:43 -05:00
Hossain Khan 0614f59ff9 feat: migrate battery reporting to Percent-Charged header
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)
2026-02-05 19:37:50 -05:00
Hossain KhanandGitHub 52a31f63e0 Merge pull request #251 from usetrmnl/feature/wifi-signal-strength-reporting
feat: Add WiFi signal strength (RSSI) reporting for BYOD devices
2026-01-31 21:45:46 -05:00
Hossain Khan 662641fa39 test: Add comprehensive tests for WiFi signal strength (RSSI) feature
- 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.
2026-01-31 21:38:30 -05:00
Hossain Khan 49a38d6182 test: Fix unit tests by adding rssi parameter to API mocks
- Add rssi parameter to all getNextDisplayData() mock calls
- Fixes failing testDebugUnitTest task on CI
2026-01-31 21:28:28 -05:00
Hossain Khan 17bc9de8ca feat: Add WiFi signal strength (RSSI) reporting for BYOD devices
- 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.
2026-01-31 21:10:59 -05:00
Hossain KhanandGitHub af65134527 Merge pull request #250 from usetrmnl/fix/240-complete-url-migration
docs: Update remaining usetrmnl.com references to trmnl.com
2026-01-31 17:02:09 -05:00
Hossain Khan 18a538be87 docs: Update remaining usetrmnl.com references to trmnl.com
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
2026-01-31 16:57:03 -05:00
Hossain KhanandGitHub 7278f075c9 Merge pull request #249 from usetrmnl/fix/240-update-urls-to-trmnl-com
docs: Update all URLs from usetrmnl.com to trmnl.com
2026-01-31 16:49:26 -05:00
Hossain Khan b7e517eeb6 docs: Update all URLs from usetrmnl.com to trmnl.com
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-com

Fixes #240
2026-01-31 16:43:41 -05:00
Hossain KhanandGitHub c12c5a423d Merge pull request #247 from usetrmnl/feature/246-byod-device-id-battery-reporting
feat: Add BYOD device ID fetching and battery reporting
2026-01-31 16:23:12 -05:00
Hossain Khan 8737038c16 fix: Include deviceId when saving config after validation
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.
2026-01-31 16:15:04 -05:00
5be5695bc7 Update app/src/main/java/ink/trmnl/android/data/TrmnlDisplayRepository.kt
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-31 16:05:49 -05:00
3a9b1e9e71 Update app/src/main/java/ink/trmnl/android/data/TrmnlDisplayRepository.kt
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-31 16:05:17 -05:00
Hossain Khan 60e18686b5 refactor: Extract battery level logic and simplify battery reporting
- 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.
2026-01-31 14:13:33 -05:00
Hossain Khan ff54c47a59 [FIXED] Unit tests 2026-01-31 13:57:14 -05:00
Hossain Khan 2e0196be52 [MINOR] Logging 2026-01-31 13:49:19 -05:00
Hossain Khan 78e0b265c8 [ADDED] Some note and references 2026-01-31 13:41:48 -05:00
Hossain Khan 61216a3c43 test: Add comprehensive test coverage for device ID and battery reporting
- 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
2026-01-31 13:35:33 -05:00
Hossain Khan a8d4066af2 docs: Clarify deviceId is BYOD-only in documentation 2026-01-31 13:26:57 -05:00
Hossain Khan 7976e77509 feat: Add BYOD device ID fetching and battery reporting (#246)
- 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.
2026-01-31 13:21:51 -05:00
Hossain KhanandGitHub 4227e32f05 Merge pull request #244 from usetrmnl/docs/document-datastore-preference-strategy
Add logging and documentation for DataStore preference strategy
2026-01-31 12:33:33 -05:00
Hossain Khan eacd144162 [MINOR] Simplify logs 2026-01-31 12:29:04 -05:00
Hossain Khan d8e653235d refactor: Extract token obfuscation into private extension function
- 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
2026-01-31 12:21:57 -05:00
Hossain KhanandGitHub e314555245 Merge pull request #243 from usetrmnl/feature/byod-user-api-token-validation
Add BYOD User API Token Validation with /api/me Endpoint
2026-01-31 10:28:45 -05:00