diff options
author | Nick Pelly <npelly@google.com> | 2012-01-25 13:28:37 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-01-25 13:28:37 -0800 |
commit | c72f76e1d3124d77e69cf8f40da3dfe8bb87da81 (patch) | |
tree | 3cc1b4221ed1f4d9b2750e3efeee4c4dd0aa2357 | |
parent | 33a6dc7c85f60daff58895842f18786fa90c4bc9 (diff) | |
parent | ac71f70c31f38d5f99e5d3bb06ea08cdf107b948 (diff) | |
download | android_packages_providers_DownloadProvider-c72f76e1d3124d77e69cf8f40da3dfe8bb87da81.tar.gz android_packages_providers_DownloadProvider-c72f76e1d3124d77e69cf8f40da3dfe8bb87da81.tar.bz2 android_packages_providers_DownloadProvider-c72f76e1d3124d77e69cf8f40da3dfe8bb87da81.zip |
am ac71f70c: Update DownloadProvider for new Intent.normalizeMimeType() API.
* commit 'ac71f70c31f38d5f99e5d3bb06ea08cdf107b948':
Update DownloadProvider for new Intent.normalizeMimeType() API.
-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) { |