Skip to content

Android: apply bsdiff patches during package install - #42

Open
ofalvai wants to merge 1 commit into
push-rzxrslvwrzvrfrom
android-apply-patches
Open

Android: apply bsdiff patches during package install#42
ofalvai wants to merge 1 commit into
push-rzxrslvwrzvrfrom
android-apply-patches

Conversation

@ofalvai

@ofalvai ofalvai commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Why

Building on top of #40, this PR integrates applyPatch() into the diff handling codepath.

What

The main change is in CodePushUpdateManager: it learns to handle the new manifest file version (which defines patch files, checksums and the patch file format), and calls BinaryDiffPatcher.

BinaryDiffPatcher does the main business logic, it walks over the patch files, applies them, and validates checksums.

I also made a series of smaller refactors to existing Java code in order to avoid code duplication or bloating existing Java classes with new code:

  • Extracted SHA-256 checksumming to its own standalone function (BinaryDiffPatches also needs this)
  • Extracted diff manifest JSON parsing to a standalone file. Manifest file parsing was ad-hoc and it was at multiple places for a single JSON field.

Out of scope

Signaling binary diff support to the server when checking for updates: the server should know what kind of delta update the client can handle (existing file-by-file diffing or binary diffing) because the manifest format is different (see below). We'll need to work out the details of this, so it's going to be a future PR.

User-facing on-off switch for the new behavior: see #43

Decisions

Manifest file version compatibility: the new manifest file format contains an explicit version field, and binary diff updates are going to set version=2. When the version field is missing, we interpret it as version=1 (file-by-file diffing only, deleted/added/modified files). We also check for version >2 and throw a hard error. The server is not supposed to send an update format that the client doesn't know how to handle, I think it's best to abort the update if this happens.

Tests: thanks to #38, new code in this PR can be unit tested instead of writing elaborate and slow E2E tests.

@ofalvai ofalvai changed the title android apply patches Android: apply bsdiff patches Aug 24, 2026
@ofalvai ofalvai changed the title Android: apply bsdiff patches Android: apply bsdiff patches during package install Aug 24, 2026
@ofalvai
ofalvai force-pushed the android-apply-patches branch 2 times, most recently from e4dc8d2 to caf918a Compare August 24, 2026 15:49
@ofalvai
ofalvai force-pushed the android-apply-patches branch from caf918a to e48ff08 Compare August 25, 2026 08:47
@ofalvai
ofalvai requested a balanced review from Copilot August 25, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds Android support for applying BSDIFF patches while installing version 2 delta updates.

Changes:

  • Parses versioned diff manifests.
  • Applies patches with path and checksum validation.
  • Adds unit tests and fixtures.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
android/app/build.gradle Adds JSON test dependency.
CodePushConstants.java Defines the patch directory name.
CodePushUpdateManager.java Integrates v2 patch installation.
CodePushUpdateUtils.java Reuses manifest and hashing utilities.
diffpatch/BinaryDiffPatcher.kt Implements validated patch application.
diffpatch/DiffManifest.kt Models and parses manifests.
diffpatch/DiffPatch.kt Adds the patch-applier abstraction.
diffpatch/Sha256.kt Provides SHA-256 helpers.
BinaryDiffPatcherTest.kt Tests patching behavior and validation.
DiffManifestTest.kt Tests manifest parsing.
Sha256Test.kt Tests checksum generation.
binarydiff/basic/old.dat Supplies the base fixture.
binarydiff/basic/new.dat Supplies the expected output fixture.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java Outdated
@ofalvai
ofalvai force-pushed the android-apply-patches branch from e48ff08 to 9738b14 Compare August 25, 2026 10:18
@ofalvai
ofalvai marked this pull request as ready for review August 25, 2026 10:21
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.

2 participants