Skip to content

Commit

Permalink
Allow dynamic patches without a patch number. (flutter#7309)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbaranov committed Dec 27, 2018
1 parent 20ee4e3 commit 732ea76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions shell/platform/android/io/flutter/view/ResourceExtractor.java
Expand Up @@ -218,19 +218,17 @@ private String checkTimestamp(File dataDir, JSONObject updateManifest) {
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();
}
}
}
}
Expand Down
Expand Up @@ -126,7 +126,7 @@ public String buildUpdateDownloadURL() {

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());
Expand Down

0 comments on commit 732ea76

Please sign in to comment.