diff options
author | 2013-04-25 17:16:03 +0900 | |
---|---|---|
committer | 2013-04-25 18:52:39 +0900 | |
commit | 43590149a5c2073a9fc8e3ed6afbf21fb017193e (patch) | |
tree | 25b064ac21c12863a79dc05fc1f1834d0a271b56 /java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java | |
parent | 4dc77dcf4c1f704c2f6b32222a74d673afec8794 (diff) | |
download | latinime-43590149a5c2073a9fc8e3ed6afbf21fb017193e.tar.gz latinime-43590149a5c2073a9fc8e3ed6afbf21fb017193e.tar.xz latinime-43590149a5c2073a9fc8e3ed6afbf21fb017193e.zip |
Work around a bug in older DownloadManager versions.
This adds a number to the extension.
Note that for DownloadManager to keep this, the server
needs to send it a mime type it does not recognize. Right
now, it does not recognize application/json so it's okay,
but we'd do well to remove the content/type header from
the server to prevent problems.
Bug: 8467516
Change-Id: Ic484f66ac3f67c36f59f2c0bcb8c7fdeb6e8590d
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java index a59660954..3f917f13f 100644 --- a/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java +++ b/java/src/com/android/inputmethod/dictionarypack/UpdateHandler.java @@ -212,7 +212,12 @@ public final class UpdateHandler { private static void updateClientsWithMetadataUri(final Context context, final boolean updateNow, final String metadataUri) { PrivateLog.log("Update for metadata URI " + Utils.s(metadataUri)); - final Request metadataRequest = new Request(Uri.parse(metadataUri)); + // Adding a disambiguator to circumvent a bug in older versions of DownloadManager. + // DownloadManager also stupidly cuts the extension to replace with its own that it + // gets from the content-type. We need to circumvent this. + final String disambiguator = "#" + System.currentTimeMillis() + + com.android.inputmethod.latin.Utils.getVersionName(context) + ".json"; + final Request metadataRequest = new Request(Uri.parse(metadataUri + disambiguator)); Utils.l("Request =", metadataRequest); final Resources res = context.getResources(); @@ -351,7 +356,13 @@ public final class UpdateHandler { final int columnUri = cursor.getColumnIndex(DownloadManager.COLUMN_URI); final int error = cursor.getInt(columnError); status = cursor.getInt(columnStatus); - uri = cursor.getString(columnUri); + final String uriWithAnchor = cursor.getString(columnUri); + int anchorIndex = uriWithAnchor.indexOf('#'); + if (anchorIndex != -1) { + uri = uriWithAnchor.substring(0, anchorIndex); + } else { + uri = uriWithAnchor; + } if (DownloadManager.STATUS_SUCCESSFUL != status) { Log.e(TAG, "Permanent failure of download " + downloadId + " with error code: " + error); |