Skip to content

Send the binary hash in update_check on Android too - #110

Draft
ofalvai wants to merge 2 commits into
masterfrom
android-send-binary-hash
Draft

ofalvai wants to merge 2 commits into
masterfrom
android-send-binary-hash

Conversation

@ofalvai

@ofalvai ofalvai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

What

When no CodePush update is installed, checkForUpdate now sends the binary's package hash on Android as it already does on iOS. The query-package decision moved from CodePush.js into a small TS function, buildQueryPackage in src/, so it can be unit tested without react-native. The now-stale case 4 comment in checkForUpdate is reworded, and the unused Platform import is removed.

Why

The server can then log which hashes Android devices report, to check that they match hashes extracted from store builds (part of the delta-updates-for-store-releases design). Shipping this early gives that data before anything depends on it.

Android already computes the hash natively, so there is no new native cost. It is still null in debug builds, so nothing is sent there. If the server answers with the binary's own hash, the existing check in checkForUpdate ignores it. The Android binary-patch path in CodePushUpdateManager still refuses, and the server has no store-build patch bases yet, so it can't be reached.

Verification

  • npm run lint, npm run typecheck, npm run build:ts and npm run test:unit:js (26 passing, including 3 new buildQueryPackage tests) all pass.
  • No iOS or Android E2E run.

Unverified

  • The server must tolerate an Android binary hash it doesn't know. I haven't checked this.
  • I haven't checked whether any analytics keyed on package_hash change when Android starts sending it.

🤖 Generated with Claude Code

ofalvai and others added 2 commits November 5, 2026 11:01
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:02

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.

🔵 Needs a closer look

Production handling of unknown Android binary hashes remains unverified, including update-check acceptance and full-update selection, which is essential because Android cannot apply diffs against the embedded binary.

No open issues 🎉

What changed in this PR

This PR makes Android report the binary package hash during update checks when no CodePush update is installed, matching iOS behavior and supporting server-side hash validation for future store-release delta updates.

Changes:

  • Extracts query-package selection into a React Native–independent TypeScript helper.
  • Adds unit tests for binary hashes, missing hashes, and installed-package precedence.
  • Integrates the helper into checkForUpdate, removes the unused Platform import, and updates the related comment.
File Description
src/​build-query-package.ts Selects the installed package or binary version and available hash.
src/​__tests__/​build-query-package.test.ts Tests the helper’s three main selection cases.
CodePush.js Uses the helper to include Android binary hashes and updates imports and commentary.

Review effort: Balanced

@ofalvai
ofalvai marked this pull request as draft November 5, 2026 12:08
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