From 732ea7669c43326d5a4b3f664d20d0a2e342c5fc Mon Sep 17 00:00:00 2001 From: Stanislav Baranov Date: Thu, 27 Dec 2018 11:56:56 -0800 Subject: [PATCH] Allow dynamic patches without a patch number. (#7309) Unique patch numbers are mainly useful for canary and A-B testing, but otherwise complicate things and can now be omitted. Also, always append .zip to patch download URL. This obviates the need to configure redirects on the server when not using patch numbers. --- .../io/flutter/view/ResourceExtractor.java | 18 ++++++++---------- .../io/flutter/view/ResourceUpdater.java | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/shell/platform/android/io/flutter/view/ResourceExtractor.java b/shell/platform/android/io/flutter/view/ResourceExtractor.java index ae8376b8a..ecf0ef5bc 100644 --- a/shell/platform/android/io/flutter/view/ResourceExtractor.java +++ b/shell/platform/android/io/flutter/view/ResourceExtractor.java @@ -218,19 +218,17 @@ class ResourceExtractor { String buildNumber = updateManifest.optString("buildNumber", null); if (buildNumber == null) { Log.w(TAG, "Invalid update manifest: buildNumber"); - } - - String patchNumber = updateManifest.optString("patchNumber", null); - if (patchNumber == null) { - Log.w(TAG, "Invalid update manifest: patchNumber"); - } - - if (buildNumber != null && patchNumber != null) { - if (!buildNumber.equals(Long.toString(getVersionCode(packageInfo)))) { + } else { + String patchNumber = updateManifest.optString("patchNumber", null); + if (!buildNumber.equals(Long.toString(getVersionCode(packageInfo)))) { Log.w(TAG, "Outdated update file for " + getVersionCode(packageInfo)); } else { final File updateFile = new File(FlutterMain.getUpdateInstallationPath()); - expectedTimestamp += "-" + patchNumber + "-" + updateFile.lastModified(); + if (patchNumber != null) { + expectedTimestamp += "-" + patchNumber + "-" + updateFile.lastModified(); + } else { + expectedTimestamp += "-" + updateFile.lastModified(); + } } } } diff --git a/shell/platform/android/io/flutter/view/ResourceUpdater.java b/shell/platform/android/io/flutter/view/ResourceUpdater.java index 3a80a07d7..7a2ee45b1 100644 --- a/shell/platform/android/io/flutter/view/ResourceUpdater.java +++ b/shell/platform/android/io/flutter/view/ResourceUpdater.java @@ -126,7 +126,7 @@ public final class ResourceUpdater { URI uri; try { - uri = new URI(metaData.getString("UpdateServerURL") + "/" + getAPKVersion()); + uri = new URI(metaData.getString("UpdateServerURL") + "/" + getAPKVersion() + ".zip"); } catch (URISyntaxException e) { Log.w(TAG, "Invalid AndroidManifest.xml UpdateServerURL: " + e.getMessage()); -- GitLab