From 646e84f85a3f463ce094ad5a9caca261277f0d0e Mon Sep 17 00:00:00 2001 From: Paul Rohde Date: Wed, 27 May 2015 15:14:59 -0700 Subject: [PATCH] Log capture session canceled events. This will handle the edgecase where capture sessions may be canceled inbetween the time the button is pressed and the capture actually starts so that it is possible to subtract these cases out of the unsaved image data. Bug: 21169512 Change-Id: Ie226d81bb10acd90dc1297230d4b024b7cd2d4d6 --- src/com/android/camera/CaptureModule.java | 14 +++++++++++++- src/com/android/camera/session/CaptureSession.java | 6 ++++++ src/com/android/camera/session/CaptureSessionImpl.java | 3 +++ src_pd/com/android/camera/stats/CaptureStats.java | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 1a0d33d9d..204dc6ace 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -456,7 +456,7 @@ public class CaptureModule extends CameraModule implements new CaptureSession.CaptureSessionCreator() { @Override public CaptureSession createAndStartEmpty() { - return createAndStartCaptureSession(); + return createAndStartUntrackedCaptureSession(); } }, deviceOrientation, @@ -562,6 +562,18 @@ public class CaptureModule extends CameraModule implements return session; } + private CaptureSession createAndStartUntrackedCaptureSession() { + long sessionTime = getSessionTime(); + Location location = mLocationManager.getCurrentLocation(); + String title = CameraUtil.instance().createJpegName(sessionTime); + CaptureSession session = getServices().getCaptureSessionManager() + .createNewSession(title, sessionTime, location); + + session.startEmpty(null, + new Size((int) mPreviewArea.width(), (int) mPreviewArea.height())); + return session; + } + private long getSessionTime() { // TODO: Replace with a mockable TimeProvider interface. return System.currentTimeMillis(); diff --git a/src/com/android/camera/session/CaptureSession.java b/src/com/android/camera/session/CaptureSession.java index 0dff1a1b3..a7f8885cd 100644 --- a/src/com/android/camera/session/CaptureSession.java +++ b/src/com/android/camera/session/CaptureSession.java @@ -99,6 +99,12 @@ public interface CaptureSession { * This occurs after all the bytes are physically on disk. */ public void onCapturePersisted(); + + /** + * This occurs if a capture session is created but is later canceled for + * some reason. + */ + public void onCaptureCanceled(); } /** Returns the title/name of this session. */ diff --git a/src/com/android/camera/session/CaptureSessionImpl.java b/src/com/android/camera/session/CaptureSessionImpl.java index 042c24bed..95765099d 100644 --- a/src/com/android/camera/session/CaptureSessionImpl.java +++ b/src/com/android/camera/session/CaptureSessionImpl.java @@ -277,6 +277,9 @@ public class CaptureSessionImpl implements CaptureSession { if (isStarted()) { mSessionManager.removeSession(mUri); mSessionNotifier.notifyTaskCanceled(mUri); + if (mImageLifecycleListener != null) { + mImageLifecycleListener.onCaptureCanceled(); + } } if (mPlaceHolder != null) { diff --git a/src_pd/com/android/camera/stats/CaptureStats.java b/src_pd/com/android/camera/stats/CaptureStats.java index 72ff1824d..a00678b9c 100644 --- a/src_pd/com/android/camera/stats/CaptureStats.java +++ b/src_pd/com/android/camera/stats/CaptureStats.java @@ -33,4 +33,8 @@ public class CaptureStats implements ImageLifecycleListener { @Override public void onCapturePersisted() { } + + @Override + public void onCaptureCanceled() { + } } -- 2.11.0