Android: apply bsdiff patches during package install - #42
Open
ofalvai wants to merge 1 commit into
Open
Conversation
ofalvai
force-pushed
the
android-apply-patches
branch
2 times, most recently
from
August 24, 2026 15:49
e4dc8d2 to
caf918a
Compare
ofalvai
force-pushed
the
android-apply-patches
branch
from
August 25, 2026 08:47
caf918a to
e48ff08
Compare
There was a problem hiding this comment.
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.
ofalvai
force-pushed
the
android-apply-patches
branch
from
August 25, 2026 10:18
e48ff08 to
9738b14
Compare
ofalvai
marked this pull request as ready for review
August 25, 2026 10:21
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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 callsBinaryDiffPatcher.BinaryDiffPatcherdoes 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:
BinaryDiffPatchesalso needs this)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
versionfield, and binary diff updates are going to setversion=2. When theversionfield is missing, we interpret it asversion=1(file-by-file diffing only, deleted/added/modified files). We also check forversion >2and 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.