aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorherriojr <jherriott@cyngn.com>2015-08-05 18:01:47 -0700
committerJon Herriott <jherriott@cyngn.com>2015-08-05 18:29:11 -0700
commitbc72332144b0948e0714a48959e7456301a52ef2 (patch)
treeb35681b26b82b6a598279db76f1cd4f0ff9da5f5
parent51e49c9b6f1e769d40cb4392a275491bd6f57d23 (diff)
downloadandroid_packages_apps_CMFileManager-caf/cm-12.0.tar.gz
android_packages_apps_CMFileManager-caf/cm-12.0.tar.bz2
android_packages_apps_CMFileManager-caf/cm-12.0.zip
Fixed ANR & Memory Leak Associated with 3GPcaf/cm-12.0
We are now defaulting to treating 3GP files as video files for determining the default icon as it was parsing the video files for their metadata which was causing ANR problems. On top of this, it was discovered that the metadata parser was leaking memory. Change-Id: I88f6cf3d8ae1a62d1294bd3272b27715c2352525 Ticket: QRDL-931 (cherry picked from commit 6f6094da21960569b93f6171e39e211e8d37f41a)
-rw-r--r--src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java3
-rw-r--r--src/com/cyanogenmod/filemanager/util/AmbiguousExtensionHelper.java2
-rw-r--r--src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java21
3 files changed, 23 insertions, 3 deletions
diff --git a/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java b/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java
index 2685cf24..dac15d43 100644
--- a/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java
+++ b/src/com/cyanogenmod/filemanager/adapters/FileSystemObjectAdapter.java
@@ -204,7 +204,8 @@ public class FileSystemObjectAdapter
FileSystemObject fso = getItem(position);
- Drawable dwIcon = this.mIconHolder.getDrawable(MimeTypeHelper.getIcon(getContext(), fso));
+ Drawable dwIcon = this.mIconHolder.getDrawable(
+ MimeTypeHelper.getIcon(getContext(), fso, true));
mIconHolder.loadDrawable(viewHolder.mIvIcon, fso, dwIcon);
viewHolder.mTvName.setText(fso.getName());
diff --git a/src/com/cyanogenmod/filemanager/util/AmbiguousExtensionHelper.java b/src/com/cyanogenmod/filemanager/util/AmbiguousExtensionHelper.java
index 3aaeb691..3b09367b 100644
--- a/src/com/cyanogenmod/filemanager/util/AmbiguousExtensionHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/AmbiguousExtensionHelper.java
@@ -74,6 +74,8 @@ public abstract class AmbiguousExtensionHelper {
}
} catch (RuntimeException e) {
Log.e(TAG, "Unable to open 3GP file to determine mimetype");
+ } finally {
+ retriever.release();
}
// Default to video 3gp if the file is unreadable as this was the default before
// ambiguous resolution support was added.
diff --git a/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java b/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java
index 36874626..1ef77ed4 100644
--- a/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java
+++ b/src/com/cyanogenmod/filemanager/util/MimeTypeHelper.java
@@ -265,6 +265,10 @@ public final class MimeTypeHelper {
* @return String The associated mime/type icon resource identifier
*/
public static final String getIcon(Context context, FileSystemObject fso) {
+ return getIcon(context, fso, false);
+ }
+
+ public static final String getIcon(Context context, FileSystemObject fso, boolean firstFound) {
//Ensure that mime types are loaded
if (sMimeTypes == null) {
loadMimeTypes(context);
@@ -288,7 +292,7 @@ public final class MimeTypeHelper {
//Get the extension and delivery
String ext = FileHelper.getExtension(fso);
if (ext != null) {
- MimeTypeInfo mimeTypeInfo = getMimeTypeInternal(fso, ext);
+ MimeTypeInfo mimeTypeInfo = getMimeTypeInternal(fso, ext, firstFound);
if (mimeTypeInfo != null) {
// Create a new drawable
@@ -434,6 +438,13 @@ public final class MimeTypeHelper {
private static final MimeTypeInfo getMimeTypeInternal(FileSystemObject fso, String ext) {
return getMimeTypeInternal(fso.getFullPath(), ext);
}
+
+ private static final MimeTypeInfo getMimeTypeInternal(FileSystemObject fso,
+ String ext,
+ boolean firstFound) {
+ return getMimeTypeInternal(fso.getFullPath(), ext, firstFound);
+ }
+
/**
* Get the MimeTypeInfo that describes this file.
* @param absolutePath The absolute path of the file.
@@ -441,10 +452,16 @@ public final class MimeTypeHelper {
* @return The MimeTypeInfo object that describes this file, or null if it cannot be retrieved.
*/
private static final MimeTypeInfo getMimeTypeInternal(String absolutePath, String ext) {
+ return getMimeTypeInternal(absolutePath, ext, false);
+ }
+
+ private static final MimeTypeInfo getMimeTypeInternal(String absolutePath,
+ String ext,
+ boolean firstFound) {
MimeTypeInfo mimeTypeInfo = null;
ArrayList<MimeTypeInfo> mimeTypeInfoList = sMimeTypes.get(ext.toLowerCase(Locale.ROOT));
// Multiple mimetypes map to the same extension, try to resolve it.
- if (mimeTypeInfoList != null && mimeTypeInfoList.size() > 1) {
+ if (mimeTypeInfoList != null && mimeTypeInfoList.size() > 1 && !firstFound) {
if (absolutePath != null) {
String mimeType = getAmbiguousExtensionMimeType(absolutePath, ext);
mimeTypeInfo = sExtensionMimeTypes.get(ext + mimeType);