Commit e901325
fix(android): match copied resources by content (CRC32) for AAB installs
A from-package (PATCH_FROM_APK) hot update copies unchanged resources out
of the on-device package using the path recorded in __diff.json `copies`.
When the baseline uploaded to the server was an APK but the app is
installed from an AAB (Play split APKs), res/ drawable paths are shortened
on device, so the recorded path (e.g. res/drawable-xhdpi-v4/x.webp) does
not exist verbatim and images (webp) silently fall through and go missing.
Add a CRC32 content-match tier in BundledResourceCopier: build a
crc32 -> entry index while scanning the base + split APKs, and when a
`from` path is not found by exact/normalized path, locate the file by the
content checksum supplied via the new manifest `copiesCrc` map. CRC32 is
over the uncompressed content, so it is stable across APK/AAB packaging.
This tier runs before resolveBundledResource (content match is more
reliable than the resource-id heuristic).
Also fix openResolvedResourceStream: use openRawResource(id, typedValue)
with the density-resolved TypedValue instead of openRawResource(id), which
ignored the requested density and could copy the wrong variant.
Backward/forward compatible: manifests without `copiesCrc` (older CLI)
simply skip the CRC tier and fall back to today's path-based behavior.
Requires CLI support: reactnativecn/react-native-update-cli#54
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent edc40be commit e901325
2 files changed
Lines changed: 52 additions & 7 deletions
File tree
- android/src/main/java/cn/reactnative/modules/update
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
| |||
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
58 | 72 | | |
59 | 73 | | |
60 | 74 | | |
| |||
87 | 101 | | |
88 | 102 | | |
89 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
90 | 118 | | |
91 | 119 | | |
92 | 120 | | |
| |||
243 | 271 | | |
244 | 272 | | |
245 | 273 | | |
246 | | - | |
| 274 | + | |
247 | 275 | | |
248 | 276 | | |
249 | 277 | | |
250 | 278 | | |
251 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
252 | 283 | | |
253 | 284 | | |
254 | 285 | | |
| |||
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
44 | 49 | | |
45 | 50 | | |
| |||
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
143 | | - | |
| 148 | + | |
| 149 | + | |
144 | 150 | | |
| 151 | + | |
| 152 | + | |
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
| |||
153 | 161 | | |
154 | 162 | | |
155 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
| |||
220 | 233 | | |
221 | 234 | | |
222 | 235 | | |
223 | | - | |
| 236 | + | |
| 237 | + | |
224 | 238 | | |
225 | 239 | | |
226 | 240 | | |
| |||
285 | 299 | | |
286 | 300 | | |
287 | 301 | | |
288 | | - | |
| 302 | + | |
289 | 303 | | |
290 | 304 | | |
291 | 305 | | |
| |||
0 commit comments