Skip to content

Fix part of #3616: Use NetworkCapabilities to detect connection status on API 29+ - #6504

Open
r0hansaxena wants to merge 3 commits into
oppia:developfrom
r0hansaxena:fix-3616-network-sdk-apis
Open

r0hansaxena wants to merge 3 commits into
oppia:developfrom
r0hansaxena:fix-3616-network-sdk-apis

Conversation

@r0hansaxena

Copy link
Copy Markdown
Collaborator

Explanation

Fixes part of #3616

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.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

Disclosure of LLM Usage

  • Did you use AI/LLMs when working on this PR? Yes
  • If yes, describe the extent AI was used: Exploring the codebase, formulating edge cases to test and formatting the PR description.

@r0hansaxena
r0hansaxena requested a review from a team as a code owner October 13, 2026 02:52
@github-actions

Copy link
Copy Markdown
Contributor

@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.

@github-actions
github-actions Bot marked this pull request as draft October 13, 2026 02:52
@r0hansaxena
r0hansaxena marked this pull request as ready for review October 13, 2026 03:10
@r0hansaxena

Copy link
Copy Markdown
Collaborator Author

I'll address the failing checks

@r0hansaxena

Copy link
Copy Markdown
Collaborator Author

@Neer-rn generic-shard3 failed, the build crashed before any tests ran. Could you re-run the CI job please?

@r0hansaxena

Copy link
Copy Markdown
Collaborator Author

thanks @Neer-rn , the comment coverage check ran before the artifact existed, could you please re run it?

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Results

Number of files assessed: 4
Overall Coverage: 97.10%
Coverage Analysis: PASS ✅

Passing coverage

Files with passing code coverage
File Coverage Lines Hit Status Min Required
NetworkConnectionUtilProdImpl.ktutility/src/main/java/org/oppia/android/util/networking/NetworkConnectionUtilProdImpl.kt
96.55% 28 / 29 ✅ 70%
NetworkConnectionUtilDebugImpl.ktutility/src/main/java/org/oppia/android/util/networking/NetworkConnectionUtilDebugImpl.kt
90.91% 10 / 11 ✅ 70%
NetworkConnectionTestUtil.kttesting/src/main/java/org/oppia/android/testing/networking/NetworkConnectionTestUtil.kt
100.00% 29 / 29 ✅ 70%

Exempted coverage

Files exempted from coverage
File Exemption Reason
SyncStatusManagerTestBase.ktutility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

@r0hansaxena

Copy link
Copy Markdown
Collaborator Author

@adhiamboperes PTAL

@oppiabot oppiabot Bot assigned adhiamboperes and unassigned r0hansaxena Oct 14, 2026
@oppiabot

oppiabot Bot commented Oct 14, 2026

Copy link
Copy Markdown

Unassigning @r0hansaxena since a re-review was requested. @r0hansaxena, please make sure you have addressed all review comments. Thanks!

@adhiamboperes

Copy link
Copy Markdown
Contributor

@ShankhanilSaha, PTAL for a first pass.

@oppiabot

oppiabot Bot commented Oct 26, 2026

Copy link
Copy Markdown

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.

@oppiabot oppiabot Bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Oct 26, 2026
@oppiabot oppiabot Bot closed this Nov 2, 2026
@adhiamboperes adhiamboperes reopened this Nov 4, 2026
@oppiabot oppiabot Bot 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
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