am 47c5846d: am 43590149: Work around a bug in older DownloadManager versions.

* commit '47c5846dae1452e5e0e480cef91838ebe1d01a48':
  Work around a bug in older DownloadManager versions.
main
Jean Chalard 2013-05-15 11:04:45 -07:00 committed by Android Git Automerger
commit e6b7fa9310
4 changed files with 21 additions and 5 deletions

View File

@ -138,7 +138,12 @@ public final class ActionBatch {
if (null == manager) return;
// This is an upgraded word list: we should download it.
final Uri uri = Uri.parse(mWordList.mRemoteFilename);
// 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) + ".dict";
final Uri uri = Uri.parse(mWordList.mRemoteFilename + disambiguator);
final Request request = new Request(uri);
final Resources res = context.getResources();

View File

@ -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);

View File

@ -122,7 +122,7 @@ public final class DebugSettings extends PreferenceFragment
}
boolean isDebugMode = mDebugMode.isChecked();
final String version = getResources().getString(
R.string.version_text, Utils.getSdkVersion(getActivity()));
R.string.version_text, Utils.getVersionName(getActivity()));
if (!isDebugMode) {
mDebugMode.setTitle(version);
mDebugMode.setSummary("");

View File

@ -475,7 +475,7 @@ public final class Utils {
return 0;
}
public static String getSdkVersion(Context context) {
public static String getVersionName(Context context) {
try {
if (context == null) {
return "";