Merge "Add android:onClick methods to proguard.flags" into ics-mr0
diff --git a/src/com/android/camera/EffectsRecorder.java b/src/com/android/camera/EffectsRecorder.java
index 9b3e3b1..8f72a8b 100644
--- a/src/com/android/camera/EffectsRecorder.java
+++ b/src/com/android/camera/EffectsRecorder.java
@@ -46,6 +46,7 @@
 import java.io.FileNotFoundException;
 import java.io.File;
 import java.lang.Runnable;
+import java.io.FileDescriptor;
 
 
 /**
@@ -84,6 +85,7 @@
     private MediaRecorder.OnErrorListener mErrorListener;
 
     private String mOutputFile;
+    private FileDescriptor mFd;
     private int mOrientationHint = 0;
     private int mCameraFacing = Camera.CameraInfo.CAMERA_FACING_BACK;
 
@@ -110,7 +112,7 @@
     private static final int STATE_RELEASED               = 4;
     private int mState = STATE_CONFIGURE;
 
-    private boolean mLogVerbose = true; //Log.isLoggable(TAG, Log.VERBOSE);
+    private boolean mLogVerbose = Log.isLoggable(TAG, Log.VERBOSE);
     private static final String TAG = "effectsrecorder";
 
     /** Determine if a given effect is supported at runtime
@@ -193,6 +195,21 @@
         }
 
         mOutputFile = outputFile;
+        mFd = null;
+    }
+
+    public void setOutputFile(FileDescriptor fd) {
+        switch (mState) {
+            case STATE_RECORD:
+                throw new RuntimeException("setOutputFile cannot be called while recording!");
+            case STATE_RELEASED:
+                throw new RuntimeException("setOutputFile called on an already released recorder!");
+            default:
+                break;
+        }
+
+        mOutputFile = null;
+        mFd = fd;
     }
 
     public void setPreviewDisplay(SurfaceHolder previewSurfaceHolder,
@@ -537,15 +554,21 @@
                 break;
         }
 
-        if (mOutputFile == null) {
-            throw new RuntimeException("No output file name provided!");
+        if ((mOutputFile == null) && (mFd == null)) {
+            throw new RuntimeException("No output file name or descriptor provided!");
         }
 
         if (mState == STATE_CONFIGURE) {
             startPreview();
         }
+
         Filter recorder = mRunner.getGraph().getFilter("recorder");
-        recorder.setInputValue("outputFile", mOutputFile);
+        if (mFd != null) {
+            recorder.setInputValue("outputFileDescriptor", mFd);
+        } else {
+            recorder.setInputValue("outputFile", mOutputFile);
+        }
+
         recorder.setInputValue("orientationHint", mOrientationHint);
         if (mInfoListener != null) {
             recorder.setInputValue("infoListener", mInfoListener);
@@ -722,7 +745,11 @@
         if (mEffectsListener != null) {
             mHandler.post(new Runnable() {
                 public void run() {
-                    mEffectsListener.onEffectsError(exception, mOutputFile);
+                    if (mFd != null) {
+                        mEffectsListener.onEffectsError(exception, null);
+                    } else {
+                        mEffectsListener.onEffectsError(exception, mOutputFile);
+                    }
                 }
             });
         }
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 3bf852d..2566271 100755
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -71,6 +71,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.FileDescriptor;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Iterator;
@@ -1286,21 +1287,26 @@
         if (mIsVideoCaptureIntent && myExtras != null) {
             Uri saveUri = (Uri) myExtras.getParcelable(MediaStore.EXTRA_OUTPUT);
             if (saveUri != null) {
-                mVideoFilename = saveUri.toString();
-            } else {
-                mVideoFilename = null;
+                try {
+                    mVideoFileDescriptor =
+                            mContentResolver.openFileDescriptor(saveUri, "rw");
+                    mCurrentVideoUri = saveUri;
+                } catch (java.io.FileNotFoundException ex) {
+                    // invalid uri
+                    Log.e(TAG, ex.toString());
+                }
             }
-        } else {
-            mVideoFilename = null;
         }
 
         // TODO: Timelapse
 
         // Set output file
-        if (mVideoFilename == null) {
+        if (mVideoFileDescriptor != null) {
+            mEffectsRecorder.setOutputFile(mVideoFileDescriptor.getFileDescriptor());
+        } else {
             generateVideoFilename(mProfile.fileFormat);
+            mEffectsRecorder.setOutputFile(mVideoFilename);
         }
-        mEffectsRecorder.setOutputFile(mVideoFilename);
     }