Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47c5846d authored by Jean Chalard's avatar Jean Chalard Committed by Android Git Automerger
Browse files

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

* commit '43590149':
  Work around a bug in older DownloadManager versions.
parents 13a2e1b2 43590149
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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();
+13 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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("");
+1 −1
Original line number Diff line number Diff line
@@ -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 "";