Video capture is returning a much larger result than specified in android.intent.extra.durationLimit

Bug 8540985

We need to truncate the scrap file before writing to it, otherwise the
camera will end up writing to the previous file, leaving the previous
length if shorter. If you captured a pictures (1.2m) and then replaced
the picture with a short video (a couple hundred k), the video file
would still be 1.2m.

Change-Id: I56c913d7ac530ec5a8c5f330bc7f9aa08512c48e
diff --git a/src/com/android/mms/TempFileProvider.java b/src/com/android/mms/TempFileProvider.java
index 6e71df7..4e73a6a 100644
--- a/src/com/android/mms/TempFileProvider.java
+++ b/src/com/android/mms/TempFileProvider.java
@@ -77,7 +77,8 @@
 
             pfd = ParcelFileDescriptor.open(file,
                     ParcelFileDescriptor.MODE_READ_WRITE
-                            | android.os.ParcelFileDescriptor.MODE_CREATE);
+                            | android.os.ParcelFileDescriptor.MODE_CREATE |
+                              ParcelFileDescriptor.MODE_TRUNCATE);
         } catch (Exception ex) {
             Log.e(TAG, "getTempStoreFd: error creating pfd for " + fileName, ex);
         }