Support for loading dynamic patches in AOT mode. (flutter/engine#7744)

* Dynamic patching support for AOT mode.

* Cleanup.
This commit is contained in:
Stanislav Baranov 2019-02-08 10:47:01 -08:00 committed by GitHub
parent c2bd3dc395
commit 34bfbdf99f

View File

@ -318,31 +318,35 @@ public final class ResourceUpdater {
return false;
}
final AssetManager manager = context.getResources().getAssets();
try (InputStream is = manager.open("flutter_assets/isolate_snapshot_data")) {
CRC32 checksum = new CRC32();
int count = 0;
byte[] buffer = new byte[BUFFER_SIZE];
while ((count = is.read(buffer, 0, BUFFER_SIZE)) != -1) {
checksum.update(buffer, 0, count);
CRC32 checksum = new CRC32();
String[] checksumFiles = {
"isolate_snapshot_data",
"isolate_snapshot_instr",
"flutter_assets/isolate_snapshot_data",
};
for (String fn : checksumFiles) {
AssetManager manager = context.getResources().getAssets();
try (InputStream is = manager.open(fn)) {
int count = 0;
byte[] buffer = new byte[BUFFER_SIZE];
while ((count = is.read(buffer, 0, BUFFER_SIZE)) != -1) {
checksum.update(buffer, 0, count);
}
} catch (IOException e) {
// Skip missing files.
}
}
if (!baselineChecksum.equals(String.valueOf(checksum.getValue()))) {
Log.w(TAG, "Mismatched update file for APK");
return false;
}
return true;
} catch (IOException e) {
Log.w(TAG, "Could not read APK: " + e);
if (!baselineChecksum.equals(String.valueOf(checksum.getValue()))) {
Log.w(TAG, "Mismatched update file for APK");
return false;
}
return true;
}
void startUpdateDownloadOnce() {
if (downloadTask != null ) {
if (downloadTask != null) {
return;
}
downloadTask = new DownloadTask();