From 587590fe1002c0ec01ffe5cac29726f48e4b4f6f Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Fri, 23 Jan 2015 11:00:06 +0800 Subject: SnapdragonCamera: Fix NPE in SnapdragonCamera during monkey test The mineType will be null if get it from an invalid uri, this may happen when delete a video very quickly after taken it and back to Camera, the video data has already gone before notifyNewMeida called. Add null pointer check before use mimeType to avoid the NPE. Change-Id: I6021faf2d4016e258153f0a75419f01fdfd7ed6c CRs-Fixed: 784389 --- src/com/android/camera/CameraActivity.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/com/android/camera') diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index e9786431b..ef100fa29 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -996,6 +996,10 @@ public class CameraActivity extends Activity public void notifyNewMedia(Uri uri) { ContentResolver cr = getContentResolver(); String mimeType = cr.getType(uri); + if (mimeType == null) { + Log.e(TAG, "mimeType is NULL"); + return; + } if (mimeType.startsWith("video/")) { sendBroadcast(new Intent(CameraUtil.ACTION_NEW_VIDEO, uri)); mDataAdapter.addNewVideo(cr, uri); -- cgit v1.2.3