diff options
author | Nick Pelly <npelly@google.com> | 2012-01-09 14:11:53 -0800 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2012-01-19 16:44:19 -0800 |
commit | ac71f70c31f38d5f99e5d3bb06ea08cdf107b948 (patch) | |
tree | 3cc1b4221ed1f4d9b2750e3efeee4c4dd0aa2357 | |
parent | ca11088a57d3066408fb35d30551a0fc743a17a3 (diff) | |
download | android_packages_providers_DownloadProvider-ac71f70c31f38d5f99e5d3bb06ea08cdf107b948.tar.gz android_packages_providers_DownloadProvider-ac71f70c31f38d5f99e5d3bb06ea08cdf107b948.tar.bz2 android_packages_providers_DownloadProvider-ac71f70c31f38d5f99e5d3bb06ea08cdf107b948.zip |
Update DownloadProvider for new Intent.normalizeMimeType() API.
Change-Id: Ideeb8cbeaa4b4d82d7c9fc8197a35bf3541a22d7
-rw-r--r-- | src/com/android/providers/downloads/DownloadThread.java | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java index 9080e725..6e111339 100644 --- a/src/com/android/providers/downloads/DownloadThread.java +++ b/src/com/android/providers/downloads/DownloadThread.java @@ -20,6 +20,7 @@ import static android.Manifest.permission.MANAGE_NETWORK_POLICY; import android.content.ContentValues; import android.content.Context; +import android.content.Intent; import android.net.INetworkPolicyListener; import android.net.NetworkPolicyManager; import android.net.Proxy; @@ -103,7 +104,7 @@ public class DownloadThread extends Thread { public long mTimeLastNotification = 0; public State(DownloadInfo info) { - mMimeType = sanitizeMimeType(info.mMimeType); + mMimeType = Intent.normalizeMimeType(info.mMimeType); mRequestUri = info.mUri; mFilename = info.mFileName; mTotalBytes = info.mTotalBytes; @@ -619,7 +620,7 @@ public class DownloadThread extends Thread { if (state.mMimeType == null) { header = response.getFirstHeader("Content-Type"); if (header != null) { - state.mMimeType = sanitizeMimeType(header.getValue()); + state.mMimeType = Intent.normalizeMimeType(header.getValue()); } } header = response.getFirstHeader("ETag"); @@ -955,27 +956,6 @@ public class DownloadThread extends Thread { mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null); } - /** - * Clean up a mimeType string so it can be used to dispatch an intent to - * view a downloaded asset. - * @param mimeType either null or one or more mime types (semi colon separated). - * @return null if mimeType was null. Otherwise a string which represents a - * single mimetype in lowercase and with surrounding whitespaces trimmed. - */ - private static String sanitizeMimeType(String mimeType) { - try { - mimeType = mimeType.trim().toLowerCase(Locale.ENGLISH); - - final int semicolonIndex = mimeType.indexOf(';'); - if (semicolonIndex != -1) { - mimeType = mimeType.substring(0, semicolonIndex); - } - return mimeType; - } catch (NullPointerException npe) { - return null; - } - } - private INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() { @Override public void onUidRulesChanged(int uid, int uidRules) { |