Files
brave-core/android/java/org
Serg 079729bb4f [Android] Fix crash in BraveRewardsNativeWorker when profile is not ready (#34907)
BraveRewardsNativeWorker crashes when constructed before the browser is
fully initialized. This happens when an AlarmManager retention
notification (DAY_10/DAY_30/DAY_35) fires and the app process is started
by Android just to handle the broadcast — ProfileManager::
GetActiveUserProfile() dereferences a null g_browser_process in this
case.

The fix:
- Checks that GetActiveUserProfile() returns a valid profile before
  creating the native worker in JNI_BraveRewardsNativeWorker_Init. If it
  doesn't, the native object is not created.
- Resets the Java singleton when native init is skipped, so subsequent
  calls can retry once the browser is fully initialized.
- Adds null-profile guards to IsSupported, IsSupportedSkipRegionCheck,
  and IsRewardsEnabled which also call GetActiveUserProfile()
  independently.
- Adds null checks for getInstance() at all call sites since it can now
  return null.

Resolves: https://github.com/brave/brave-browser/issues/53877
2026-03-24 00:19:52 +01:00
..