Skip to content

Conversation

jonathanmos
Copy link
Member

@jonathanmos jonathanmos commented Aug 10, 2025

What does this PR do?

Adds some battery and display attributes to view updates. The following fields were added:

battery_level: The current battery charge level, expressed as a float from 0.0 (empty) to 1.0 (full). This is to align with ios, so we lose some granularity as android can measure to within 1% of the battery level while ios shows only to the nearest 10%. Monitored by polling once every 60 seconds - it didn't seem a good idea to register a listener as the listener was firing sometimes multiple times per second.

low_power_mode: A boolean indicating whether the device is currently in Low Power Mode. Monitored with a broadcast receiver.

brightness_level: The current screen brightness, normalized as a float between 0.0 (darkest) and 1.0 (brightest). Monitored with a content observer.

Motivation

Part of adding metadata fields.

Additional Notes

Refactor of the architecture of the info providers since we now have three providers (accessibility/battery/display) - all classes now implement the InfoProvider interface and use the same generic NoOp class. The generic interface returns a kv map and we use the concrete data classes to convert between the objects and this representation.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@jonathanmos jonathanmos force-pushed the jmoskovich/rum-11120/battery-attributes branch from 77d3e69 to aa393a5 Compare August 10, 2025 15:10
@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 85.64815% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.09%. Comparing base (c6b7a43) to head (7153c75).

Files with missing lines Patch % Lines
...ernal/domain/battery/DefaultBatteryInfoProvider.kt 79.07% 6 Missing and 3 partials ⚠️
...ernal/domain/display/DefaultDisplayInfoProvider.kt 77.42% 6 Missing and 1 partial ⚠️
...m/internal/domain/display/SystemSettingsWrapper.kt 41.67% 7 Missing ⚠️
...cessibility/DefaultAccessibilitySnapshotManager.kt 92.59% 1 Missing and 1 partial ⚠️
...al/domain/accessibility/NoOpAccessibilityReader.kt 33.33% 2 Missing ⚠️
...internal/domain/battery/NoOpBatteryInfoProvider.kt 33.33% 2 Missing ⚠️
...internal/domain/display/NoOpDisplayInfoProvider.kt 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2815      +/-   ##
===========================================
- Coverage    70.15%   70.09%   -0.06%     
===========================================
  Files          834      843       +9     
  Lines        31296    31442     +146     
  Branches      5259     5261       +2     
===========================================
+ Hits         21955    22037      +82     
- Misses        7886     7922      +36     
- Partials      1455     1483      +28     
Files with missing lines Coverage Δ
...rum/src/main/kotlin/com/datadog/android/rum/Rum.kt 88.89% <100.00%> (+0.36%) ⬆️
...lin/com/datadog/android/rum/internal/RumFeature.kt 92.88% <100.00%> (-0.29%) ⬇️
...internal/domain/accessibility/AccessibilityInfo.kt 100.00% <100.00%> (ø)
...domain/accessibility/DefaultAccessibilityReader.kt 97.73% <100.00%> (ø)
...android/rum/internal/domain/battery/BatteryInfo.kt 100.00% <100.00%> (ø)
.../rum/internal/domain/battery/SystemClockWrapper.kt 100.00% <100.00%> (ø)
...android/rum/internal/domain/display/DisplayInfo.kt 100.00% <100.00%> (ø)
...d/rum/internal/domain/scope/RumApplicationScope.kt 95.65% <100.00%> (+1.16%) ⬆️
...droid/rum/internal/domain/scope/RumSessionScope.kt 96.15% <100.00%> (+0.12%) ⬆️
...d/rum/internal/domain/scope/RumViewManagerScope.kt 92.66% <100.00%> (+0.76%) ⬆️
... and 9 more

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathanmos jonathanmos force-pushed the jmoskovich/rum-11120/battery-attributes branch from 39b52d4 to 9f737d7 Compare August 12, 2025 11:49
@jonathanmos jonathanmos marked this pull request as ready for review August 12, 2025 13:02
@jonathanmos jonathanmos requested review from a team as code owners August 12, 2025 13:02
@jonathanmos jonathanmos merged commit e83db32 into develop Aug 19, 2025
25 checks passed
@jonathanmos jonathanmos deleted the jmoskovich/rum-11120/battery-attributes branch August 19, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants