OSDN Git Service

gcam: Add postcapture for gcam debugging.
authorRuben Brunk <rubenbrunk@google.com>
Wed, 9 Oct 2013 06:31:13 +0000 (23:31 -0700)
committerRuben Brunk <rubenbrunk@google.com>
Wed, 9 Oct 2013 18:12:59 +0000 (11:12 -0700)
Bug: 11010544
Change-Id: I782bf3bd52f7b37cf47291501560ba771951760a

src/com/android/camera/CameraActivity.java
src/com/android/camera/PhotoModule.java

index 3e5a7c0..f933dd0 100644 (file)
@@ -115,6 +115,8 @@ public class CameraActivity extends Activity
      */
     public static final int REQ_CODE_DONT_SWITCH_TO_PREVIEW = 142;
 
+    public static final int REQ_CODE_GCAM_DEBUG_POSTCAPTURE = 999;
+
     private static final int HIDE_ACTION_BAR = 1;
     private static final long SHOW_ACTION_BAR_TIMEOUT_MS = 3000;
 
@@ -1474,4 +1476,9 @@ public class CameraActivity extends Activity
     public CameraOpenErrorCallback getCameraOpenErrorCallback() {
         return mCameraOpenErrorCallback;
     }
+
+    // For debugging purposes only.
+    public CameraModule getCurrentModule() {
+        return mCurrentModule;
+    }
 }
index 3c495db..ff28700 100644 (file)
@@ -158,6 +158,8 @@ public class PhotoModule
     private String mCropValue;
     private Uri mSaveUri;
 
+    private Uri mDebugUri;
+
     // We use a queue to generated names of the images to be used later
     // when the image is ready to be saved.
     private NamedImages mNamedImages;
@@ -704,7 +706,11 @@ public class PhotoModule
 
             ExifInterface exif = Exif.getExif(jpegData);
             int orientation = Exif.getOrientation(exif);
-            if (!mIsImageCaptureIntent) {
+
+            if (mDebugUri != null) {
+                // If using a debug uri, save jpeg there
+                saveToDebugUri(jpegData);
+            }else if (!mIsImageCaptureIntent) {
                 // Calculate the width and the height of the jpeg.
                 Size s = mParameters.getPictureSize();
                 int width, height;
@@ -1925,6 +1931,27 @@ public class PhotoModule
         mUI.onPreviewFocusChanged(previewFocused);
     }
 
+    // For debugging only.
+    public void setDebugUri(Uri uri) {
+        mDebugUri = uri;
+    }
+
+    // For debugging only.
+    private void saveToDebugUri(byte[] data) {
+        if (mDebugUri != null) {
+            OutputStream outputStream = null;
+            try {
+                outputStream = mContentResolver.openOutputStream(mDebugUri);
+                outputStream.write(data);
+                outputStream.close();
+            } catch (IOException e) {
+                Log.e(TAG, "Exception while writing debug jpeg file", e);
+            } finally {
+                CameraUtil.closeSilently(outputStream);
+            }
+        }
+    }
+
 /* Below is no longer needed, except to get rid of compile error
  * TODO: Remove these
  */