Merge "Fix 5224359: Add width and height to media store."
This commit is contained in:
committed by
Android (Google) Code Review
commit
ed4cfe70ca
@@ -283,6 +283,17 @@ public final class MediaStore {
|
||||
*/
|
||||
public static final String IS_DRM = "is_drm";
|
||||
|
||||
/**
|
||||
* The width of the image/video in pixels.
|
||||
* @hide
|
||||
*/
|
||||
public static final String WIDTH = "width";
|
||||
|
||||
/**
|
||||
* The height of the image/video in pixels.
|
||||
* @hide
|
||||
*/
|
||||
public static final String HEIGHT = "height";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -470,6 +470,8 @@ public class MediaScanner
|
||||
private int mCompilation;
|
||||
private boolean mIsDrm;
|
||||
private boolean mNoMedia; // flag to suppress file from appearing in media tables
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
|
||||
public FileCacheEntry beginFile(String path, String mimeType, long lastModified,
|
||||
long fileSize, boolean isDirectory, boolean noMedia) {
|
||||
@@ -545,6 +547,8 @@ public class MediaScanner
|
||||
mWriter = null;
|
||||
mCompilation = 0;
|
||||
mIsDrm = false;
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
@@ -583,6 +587,10 @@ public class MediaScanner
|
||||
processFile(path, mimeType, this);
|
||||
}
|
||||
|
||||
if (MediaFile.isImageFileType(mFileType)) {
|
||||
processImageFile(path);
|
||||
}
|
||||
|
||||
result = endFile(entry, ringtones, notifications, alarms, music, podcasts);
|
||||
}
|
||||
}
|
||||
@@ -697,6 +705,18 @@ public class MediaScanner
|
||||
return genreTagValue;
|
||||
}
|
||||
|
||||
private void processImageFile(String path) {
|
||||
try {
|
||||
mBitmapOptions.outWidth = 0;
|
||||
mBitmapOptions.outHeight = 0;
|
||||
BitmapFactory.decodeFile(path, mBitmapOptions);
|
||||
mWidth = mBitmapOptions.outWidth;
|
||||
mHeight = mBitmapOptions.outHeight;
|
||||
} catch (Throwable th) {
|
||||
// ignore;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
if ("audio/mp4".equals(mMimeType) &&
|
||||
mimeType.startsWith("video")) {
|
||||
@@ -725,6 +745,11 @@ public class MediaScanner
|
||||
map.put(MediaStore.MediaColumns.MIME_TYPE, mMimeType);
|
||||
map.put(MediaStore.MediaColumns.IS_DRM, mIsDrm);
|
||||
|
||||
if (mWidth > 0 && mHeight > 0) {
|
||||
map.put(MediaStore.MediaColumns.WIDTH, mWidth);
|
||||
map.put(MediaStore.MediaColumns.HEIGHT, mHeight);
|
||||
}
|
||||
|
||||
if (!mNoMedia) {
|
||||
if (MediaFile.isVideoFileType(mFileType)) {
|
||||
map.put(Video.Media.ARTIST, (mArtist != null && mArtist.length() > 0
|
||||
|
||||
Reference in New Issue
Block a user