am 43590149: Work around a bug in older DownloadManager versions.
* commit '43590149a5c2073a9fc8e3ed6afbf21fb017193e': Work around a bug in older DownloadManager versions.main
commit
47c5846dae
|
@ -138,7 +138,12 @@ public final class ActionBatch {
|
||||||
if (null == manager) return;
|
if (null == manager) return;
|
||||||
|
|
||||||
// This is an upgraded word list: we should download it.
|
// 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 Request request = new Request(uri);
|
||||||
|
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
|
|
|
@ -212,7 +212,12 @@ public final class UpdateHandler {
|
||||||
private static void updateClientsWithMetadataUri(final Context context,
|
private static void updateClientsWithMetadataUri(final Context context,
|
||||||
final boolean updateNow, final String metadataUri) {
|
final boolean updateNow, final String metadataUri) {
|
||||||
PrivateLog.log("Update for metadata URI " + Utils.s(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);
|
Utils.l("Request =", metadataRequest);
|
||||||
|
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
|
@ -351,7 +356,13 @@ public final class UpdateHandler {
|
||||||
final int columnUri = cursor.getColumnIndex(DownloadManager.COLUMN_URI);
|
final int columnUri = cursor.getColumnIndex(DownloadManager.COLUMN_URI);
|
||||||
final int error = cursor.getInt(columnError);
|
final int error = cursor.getInt(columnError);
|
||||||
status = cursor.getInt(columnStatus);
|
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) {
|
if (DownloadManager.STATUS_SUCCESSFUL != status) {
|
||||||
Log.e(TAG, "Permanent failure of download " + downloadId
|
Log.e(TAG, "Permanent failure of download " + downloadId
|
||||||
+ " with error code: " + error);
|
+ " with error code: " + error);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public final class DebugSettings extends PreferenceFragment
|
||||||
}
|
}
|
||||||
boolean isDebugMode = mDebugMode.isChecked();
|
boolean isDebugMode = mDebugMode.isChecked();
|
||||||
final String version = getResources().getString(
|
final String version = getResources().getString(
|
||||||
R.string.version_text, Utils.getSdkVersion(getActivity()));
|
R.string.version_text, Utils.getVersionName(getActivity()));
|
||||||
if (!isDebugMode) {
|
if (!isDebugMode) {
|
||||||
mDebugMode.setTitle(version);
|
mDebugMode.setTitle(version);
|
||||||
mDebugMode.setSummary("");
|
mDebugMode.setSummary("");
|
||||||
|
|
|
@ -475,7 +475,7 @@ public final class Utils {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSdkVersion(Context context) {
|
public static String getVersionName(Context context) {
|
||||||
try {
|
try {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return "";
|
return "";
|
||||||
|
|
Loading…
Reference in New Issue