|
24 | 24 | public class CodePushUpdateManager { |
25 | 25 |
|
26 | 26 | private String mDocumentsDirectory; |
| 27 | + private boolean mEnableBinaryDiffUpdates; |
27 | 28 |
|
28 | | - public CodePushUpdateManager(String documentsDirectory) { |
| 29 | + public CodePushUpdateManager(String documentsDirectory, boolean enableBinaryDiffUpdates) { |
29 | 30 | mDocumentsDirectory = documentsDirectory; |
| 31 | + mEnableBinaryDiffUpdates = enableBinaryDiffUpdates; |
30 | 32 | } |
31 | 33 |
|
32 | 34 | private String getDownloadFilePath() { |
@@ -260,12 +262,14 @@ public void downloadPackage(JSONObject updatePackage, String expectedBundleFileN |
260 | 262 | if (isDiffUpdate) { |
261 | 263 | // Run patching after copyNecessaryFilesFromCurrentPackage() so patched output overwrites |
262 | 264 | // bytes copied in from the old package at the same paths. |
263 | | - if (diffManifest.getVersion() == 2) { |
| 265 | + if (diffManifest.getVersion() > 2 || diffManifest.getVersion() < 1) { |
| 266 | + throw new IOException("Diff manifest version " + diffManifest.getVersion() + " is not supported by this SDK version."); |
| 267 | + } else if (diffManifest.getVersion() == 2 && !mEnableBinaryDiffUpdates) { |
| 268 | + throw new IOException("Received a binary diff update, but binary diff updates are not enabled on this client. Set CodePushEnableBinaryDiffUpdates to true in strings.xml to enable them."); |
| 269 | + } else if (diffManifest.getVersion() == 2) { |
264 | 270 | String currentPackageFolderPath = getCurrentPackageFolderPath(); |
265 | 271 | BinaryDiffPatcher.applyBinaryDiffPatches(diffManifest, new File(currentPackageFolderPath), new File(unzippedFolderPath), new File(newUpdateFolderPath)); |
266 | 272 | FileUtils.deleteDirectoryAtPath(new File(newUpdateFolderPath, CodePushConstants.DIFF_PATCHES_FOLDER_NAME).getPath()); |
267 | | - } else if (diffManifest.getVersion() > 2) { |
268 | | - throw new IOException("Diff manifest version " + diffManifest.getVersion() + " is not supported by this SDK version."); |
269 | 273 | } |
270 | 274 | } |
271 | 275 |
|
|
0 commit comments