You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix part of #3616: Use NetworkCapabilities to detect connection status on API 29+ - #6504
NetworkConnectionUtilProdImpl.getCurrentConnectionStatus() used the deprecated activeNetworkInfo for every device, regardless of SDK version.
Following the breakdown in the issue:
getCurrentConnectionStatus() now switches on the SDK version, using activeNetwork and getNetworkCapabilities on API 29+ and keeping the existing path for older devices, which is where the @Suppress("DEPRECATION") now lives.
NetworkConnectionTestUtil gains setNetworkCapabilities, which sets up the shadow capabilities so tests can cover the newer path. Robolectric shadows were enough here, so no mockito dependency was needed.
SyncStatusManagerTestBase connects and disconnects through capabilities now. Its helpers were setting legacy network info while running at the default SDK, so they stopped registering as connected once the new path went live.
Only the networking migration is covered here, the other deprecated API TODOs for this issue are untouched.
Verification
bazel test //utility/src/test/java/org/oppia/android/util/networking:all → 4 targets pass, including 21 tests in NetworkConnectionUtilProdImplTest and 18 in NetworkConnectionUtilDebugImplTest
bazel test //testing/src/test/java/org/oppia/android/testing/networking:all → passes, 7 tests in NetworkConnectionTestUtilTest
bazel test //utility/src/test/java/org/oppia/android/util/logging:SyncStatusManagerImplTest //testing/src/test/java/org/oppia/android/testing/logging:TestSyncStatusManagerTest → both pass
bazel run //scripts:regex_pattern_validation_check and //scripts:kdoc_validity_check → both pass
Ran the app on a Pixel 4 API 28 emulator and a Pixel 6 API 36 one, toggling connectivity off and on each time, no crashes on either path
Essential Checklist
The PR title starts with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
The explanation section above starts with "Fixes #bugnum: " (If this PR fixes part of an issue, use instead: "Fixes part of #bugnum: ...".)
Any changes to scripts/assets files have their rationale included in the PR explanation.
@r0hansaxena this PR is being marked as draft because you are not assigned to referenced issue #3616 (or it does not exist). You may only fix issues that you are assigned to to help avoid multiple team members duplicating work on the same issue.
Hi @r0hansaxena, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you! If you're unsure how to reassign this PR to a reviewer, please make sure to review the wiki page that details the Guidance on submitting PRs.
oppiabotBot
added
the
stale
Corresponds to items that haven't seen a recent update and may be automatically closed.
label
Oct 26, 2026
oppiabotBot
removed
the
stale
Corresponds to items that haven't seen a recent update and may be automatically closed.
label
Nov 4, 2026
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Fixes part of #3616
NetworkConnectionUtilProdImpl.getCurrentConnectionStatus()used the deprecatedactiveNetworkInfofor every device, regardless of SDK version.Following the breakdown in the issue:
getCurrentConnectionStatus()now switches on the SDK version, usingactiveNetworkandgetNetworkCapabilitieson API 29+ and keeping the existing path for older devices, which is where the@Suppress("DEPRECATION")now lives.NetworkConnectionTestUtilgainssetNetworkCapabilities, which sets up the shadow capabilities so tests can cover the newer path. Robolectric shadows were enough here, so no mockito dependency was needed.SyncStatusManagerTestBaseconnects and disconnects through capabilities now. Its helpers were setting legacy network info while running at the default SDK, so they stopped registering as connected once the new path went live.Only the networking migration is covered here, the other deprecated API TODOs for this issue are untouched.
Verification
bazel test //utility/src/test/java/org/oppia/android/util/networking:all→ 4 targets pass, including 21 tests inNetworkConnectionUtilProdImplTestand 18 inNetworkConnectionUtilDebugImplTestbazel test //testing/src/test/java/org/oppia/android/testing/networking:all→ passes, 7 tests inNetworkConnectionTestUtilTestbazel test //utility/src/test/java/org/oppia/android/util/logging:SyncStatusManagerImplTest //testing/src/test/java/org/oppia/android/testing/logging:TestSyncStatusManagerTest→ both passbazel run //scripts:regex_pattern_validation_checkand//scripts:kdoc_validity_check→ both passEssential Checklist
Disclosure of LLM Usage