Skip to content

Fix part of #5405: Replace deprecated Bundle calls with BundleCompat#6245

Open
akkicodes-dev wants to merge 4 commits into
oppia:developfrom
akkicodes-dev:fix/bundle-compat-migration-v2
Open

Fix part of #5405: Replace deprecated Bundle calls with BundleCompat#6245
akkicodes-dev wants to merge 4 commits into
oppia:developfrom
akkicodes-dev:fix/bundle-compat-migration-v2

Conversation

@akkicodes-dev

Copy link
Copy Markdown

Explanation

Problem
Android API 33 deprecated several type-ambiguous Bundle methods like getSerializable() (without type parameter). These methods are unsafe because they don't enforce type checking at compile time, which can lead to runtime ClassCastException errors. The existing code in BundleExtensions.kt had a TODO(#5405) to migrate this to BundleCompat.

Solution
Replaced the deprecated Bundle calls with BundleCompat.getSerializable() from AndroidX Core, which provides a type-safe, backward-compatible implementation that works correctly across all API levels without requiring manual API version checks.

Changes Made

  1. third_party/versions.bzl — Upgraded androidx.core:core and androidx.core:core-ktx from 1.0.1 to 1.9.0 to enable BundleCompat usage.

  2. utility/src/main/java/org/oppia/android/util/extensions/BundleExtensions.kt — Removed the TODO(#5405) comment. Replaced the manual API-version-checking implementation with a single clean call to BundleCompat.getSerializable(). Removed unused imports and added androidx.core.os.BundleCompat.

  3. utility/src/main/java/org/oppia/android/util/extensions/BUILD.bazel — Added //third_party:androidx_core_core as a dependency.

  4. app/src/main/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivity.kt — Removed @Suppress("DEPRECATION") annotation and its associated TODO(#5405) comment.

  5. utility/src/test/java/org/oppia/android/util/extensions/BundleExtensionsTest.kt — Removed the TODO(#5405) comment.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix 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.
  • 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.

Fixes part of #5405

@akkicodes-dev
akkicodes-dev requested review from a team as code owners April 26, 2026 07:17
@akkicodes-dev

Copy link
Copy Markdown
Author

Hi @adhiamboperes,

This PR replaces the deprecated Bundle.getSerializable() calls with BundleCompat.getSerializable() from AndroidX Core, resolving the TODO(#5405) in BundleExtensions.kt.

The implementation is cleaner and type-safe — removing the need for manual API version checks and @Suppress("DEPRECATION") annotations.

@adhiamboperes PTAL

@adhiamboperes adhiamboperes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akkicodes-dev!

However, I have left some comments in-line.

Additionally:

  • Your PR description does not start with
  • "Fixes #". I believe this issue is small enough to be fixed in one go. Please work on the other files mentioned in #5405 once your approach has been approved.

Comment on lines -23 to -24
@Suppress("DEPRECATION") // TODO(#5405): Ensure the correct type is being retrieved.
val readingTextSize = checkNotNull(

@adhiamboperes adhiamboperes Apr 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The supress annotation is removed but no change haas been made, why?

Comment thread third_party/versions.bzl
Comment thread third_party/versions.bzl
Comment thread utility/src/main/java/org/oppia/android/util/extensions/BundleExtensions.kt Outdated

assertThat(intent).extras().hasSize(1)
assertThat(intent).extras().containsKey("first_extra")
// TODO(#5405): Convert this to getSerializableExtra once Robolectric can be updated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any changes supporting the removal of this TODO, unless I am missing something.

@akkicodes-dev
akkicodes-dev requested a review from a team as a code owner April 29, 2026 10:26
@akkicodes-dev
akkicodes-dev requested a review from manas-yu April 29, 2026 10:26
@akkicodes-dev

Copy link
Copy Markdown
Author

Hi @adhiamboperes,

I have addressed all the review comments:

  • Fixed indentation in versions.bzl for androidx.core:core-ktx
  • Re-pinned Maven dependencies as per the wiki
  • Added newline at end of BundleExtensions.kt
  • TestFontScaleConfigurationUtilActivity.kt and BundleExtensionsTest.kt were already clean after merging latest develop

PTAL!

@oppiabot oppiabot Bot assigned adhiamboperes and unassigned akkicodes-dev Apr 29, 2026
@oppiabot

oppiabot Bot commented Apr 29, 2026

Copy link
Copy Markdown

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

@oppiabot

oppiabot Bot commented May 6, 2026

Copy link
Copy Markdown

Hi @akkicodes-dev, 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 May 6, 2026
@adhiamboperes adhiamboperes removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 6, 2026

@adhiamboperes adhiamboperes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runs are failing because of a missing dependency. The androidx core dependency should be added to the BUILD file related to BundleExtensions.kt
Image

Comment on lines +76 to +77


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added 2 newlines instead of just one.

@akkicodes-dev

Copy link
Copy Markdown
Author

Hi @adhiamboperes,

Addressed all review comments:

  • Added //third_party:androidx_core_core dependency in BUILD.bazel for bundle_extensions
  • Fixed extra newline at end of BundleExtensions.kt

PTAL!

@oppiabot oppiabot Bot assigned adhiamboperes and unassigned akkicodes-dev May 13, 2026
@oppiabot

oppiabot Bot commented May 13, 2026

Copy link
Copy Markdown

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

@oppiabot

oppiabot Bot commented May 20, 2026

Copy link
Copy Markdown

Hi @akkicodes-dev, 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 May 20, 2026
@adhiamboperes adhiamboperes removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 22, 2026
@oppiabot

oppiabot Bot commented May 29, 2026

Copy link
Copy Markdown

Hi @akkicodes-dev, 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 May 29, 2026

@adhiamboperes adhiamboperes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akkicodes-dev!

I think you can proceed with working on the other files mentioned in the issue, so that this PR can close the issue, not just part of it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has removed some spaces, and I am not sure why.

@oppiabot oppiabot Bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 30, 2026
@oppiabot

oppiabot Bot commented Jun 6, 2026

Copy link
Copy Markdown

Hi @akkicodes-dev, 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 Jun 6, 2026
@oppiabot oppiabot Bot closed this Jun 13, 2026
@akkicodes-dev

Copy link
Copy Markdown
Author

"Reopening this PR — addressing all pending review comments and expanding scope to fully close #5405."
@adhiamboperes

@Neer-rn Neer-rn reopened this Jul 7, 2026
@oppiabot oppiabot Bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jul 7, 2026
@Neer-rn

Neer-rn commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Hi @akkicodes-dev, is this PR ready for another review, or are you still working on it?

If it’s ready for review, please assign a reviewer and leave a comment like PTAL @username. Otherwise, we may not know whether it’s ready for review or still in progress.

Also, please resolve the merge conflict before asking for another review. Thank you!!!

@oppiabot

oppiabot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Hi @akkicodes-dev, 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 Jul 14, 2026
@Neer-rn Neer-rn removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Jul 14, 2026
@Neer-rn

Neer-rn commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Hi @akkicodes-dev, another friendly ping.

@oppiabot

oppiabot Bot commented Jul 21, 2026

Copy link
Copy Markdown

Hi @akkicodes-dev, 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 Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Corresponds to items that haven't seen a recent update and may be automatically closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants