Skip to content

RUM-16604: Read process importance early#3504

Merged
0xnm merged 1 commit into
developfrom
nogorodnikov/rum-16604/read-process-importance-early
Jun 3, 2026
Merged

RUM-16604: Read process importance early#3504
0xnm merged 1 commit into
developfrom
nogorodnikov/rum-16604/read-process-importance-early

Conversation

@0xnm

@0xnm 0xnm commented Jun 3, 2026

Copy link
Copy Markdown
Member

What does this PR do?

In case of https://developer.android.com/topic/libraries/app-startup usage Datadog SDK may be started from the Content Provider.

And since we use process importance to start RUM pipeline

override fun start() {
val processImportance = DdRumContentProvider.processImportance
val isAppInForeground = processImportance ==
ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
handleEvent(
RumRawEvent.SdkInit(isAppInForeground)
)
}

and process importance is read in another Content Provider

override fun onCreate(): Boolean {
if (processImportance == 0) {
val manager = context?.getSystemServiceAs<ActivityManager>(Context.ACTIVITY_SERVICE)
val currentProcessId = Process.myPid()
val currentProcess = manager?.runningAppProcesses?.firstOrNull {
it.pid == currentProcessId
}
processImportance = currentProcess?.importance ?: DEFAULT_IMPORTANCE
Log.w("DdRumContentProvider", "processImportance:$processImportance")
}
return true
}

we may have it not yet available by the time SDK starts, because it all depends on the initialization order.

This PR does the following:

  • assigns initOrder to the DdRumContentProvider, so it has a priority in the startup list
  • switches to getMyMemoryState API. It is available since API 16, so it is safe to use
  • to support rare cases when process importance is requested before DdRumContentProvider is initialized, we try to read it in the getter as well.

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)

@codecov-commenter

codecov-commenter commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.14%. Comparing base (e9efd7c) to head (f11df77).

Files with missing lines Patch % Lines
...va/com/datadog/android/rum/DdRumContentProvider.kt 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3504      +/-   ##
===========================================
- Coverage    72.22%   72.14%   -0.07%     
===========================================
  Files          965      965              
  Lines        35596    35602       +6     
  Branches      5935     5932       -3     
===========================================
- Hits         25706    25685      -21     
- Misses        8278     8292      +14     
- Partials      1612     1625      +13     
Files with missing lines Coverage Δ
...va/com/datadog/android/rum/DdRumContentProvider.kt 95.45% <93.33%> (+7.95%) ⬆️

... and 36 files with indirect coverage changes

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

@0xnm
0xnm marked this pull request as ready for review June 3, 2026 14:06
@0xnm
0xnm requested review from a team as code owners June 3, 2026 14:07
@0xnm
0xnm force-pushed the nogorodnikov/rum-16604/read-process-importance-early branch from a4876d0 to f11df77 Compare June 3, 2026 14:54
@0xnm
0xnm merged commit 7720f9c into develop Jun 3, 2026
27 checks passed
@0xnm
0xnm deleted the nogorodnikov/rum-16604/read-process-importance-early branch June 3, 2026 15:49
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.

3 participants