summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/Camera.java57
-rwxr-xr-xtests/src/com/android/camera/stress/CameraLatency.java54
2 files changed, 67 insertions, 44 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 753d923..b60639f 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -178,6 +178,8 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
private final OneShotPreviewCallback mOneShotPreviewCallback =
new OneShotPreviewCallback();
private final ShutterCallback mShutterCallback = new ShutterCallback();
+ private final PostViewPictureCallback mPostViewPictureCallback =
+ new PostViewPictureCallback();
private final RawPictureCallback mRawPictureCallback =
new RawPictureCallback();
private final AutoFocusCallback mAutoFocusCallback =
@@ -191,6 +193,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
private long mFocusCallbackTime;
private long mCaptureStartTime;
private long mShutterCallbackTime;
+ private long mPostViewPictureCallbackTime;
private long mRawPictureCallbackTime;
private long mJpegPictureCallbackTime;
private int mPicturesRemaining;
@@ -198,9 +201,9 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
// These latency time are for the CameraLatency test.
public long mAutoFocusTime;
public long mShutterLag;
- public long mShutterAndRawPictureCallbackTime;
- public long mJpegPictureCallbackTimeLag;
- public long mRawPictureAndJpegPictureCallbackTime;
+ public long mShutterToPictureDisplayedTime;
+ public long mPictureDisplayedToJpegCallbackTime;
+ public long mJpegCallbackToFirstFrameTime;
// Add for test
public static boolean mMediaServerDied = false;
@@ -555,9 +558,9 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
android.hardware.Camera camera) {
long now = System.currentTimeMillis();
if (mJpegPictureCallbackTime != 0) {
- mJpegPictureCallbackTimeLag = now - mJpegPictureCallbackTime;
- Log.v(TAG, "mJpegPictureCallbackTimeLag = "
- + mJpegPictureCallbackTimeLag + "ms");
+ mJpegCallbackToFirstFrameTime = now - mJpegPictureCallbackTime;
+ Log.v(TAG, "mJpegCallbackToFirstFrameTime = "
+ + mJpegCallbackToFirstFrameTime + "ms");
mJpegPictureCallbackTime = 0;
} else {
Log.v(TAG, "Got first frame");
@@ -575,14 +578,22 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
}
}
+ private final class PostViewPictureCallback implements PictureCallback {
+ public void onPictureTaken(
+ byte [] data, android.hardware.Camera camera) {
+ mPostViewPictureCallbackTime = System.currentTimeMillis();
+ Log.v(TAG, "mShutterToPostViewCallbackTime = "
+ + (mPostViewPictureCallbackTime - mShutterCallbackTime)
+ + "ms");
+ }
+ }
+
private final class RawPictureCallback implements PictureCallback {
public void onPictureTaken(
byte [] rawData, android.hardware.Camera camera) {
mRawPictureCallbackTime = System.currentTimeMillis();
- mShutterAndRawPictureCallbackTime =
- mRawPictureCallbackTime - mShutterCallbackTime;
- Log.v(TAG, "mShutterAndRawPictureCallbackTime = "
- + mShutterAndRawPictureCallbackTime + "ms");
+ Log.v(TAG, "mShutterToRawCallbackTime = "
+ + (mRawPictureCallbackTime - mShutterCallbackTime) + "ms");
}
}
@@ -600,16 +611,27 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
}
mJpegPictureCallbackTime = System.currentTimeMillis();
- mRawPictureAndJpegPictureCallbackTime =
- mJpegPictureCallbackTime - mRawPictureCallbackTime;
- Log.v(TAG, "mRawPictureAndJpegPictureCallbackTime = "
- + mRawPictureAndJpegPictureCallbackTime + "ms");
+ // If postview callback has arrived, the captured image is displayed
+ // in postview callback. If not, the captured image is displayed in
+ // raw picture callback.
+ if (mPostViewPictureCallbackTime != 0) {
+ mShutterToPictureDisplayedTime =
+ mPostViewPictureCallbackTime - mShutterCallbackTime;
+ mPictureDisplayedToJpegCallbackTime =
+ mJpegPictureCallbackTime - mPostViewPictureCallbackTime;
+ } else {
+ mShutterToPictureDisplayedTime =
+ mRawPictureCallbackTime - mShutterCallbackTime;
+ mPictureDisplayedToJpegCallbackTime =
+ mJpegPictureCallbackTime - mRawPictureCallbackTime;
+ }
+ Log.v(TAG, "mPictureDisplayedToJpegCallbackTime = "
+ + mPictureDisplayedToJpegCallbackTime + "ms");
if (!mIsImageCaptureIntent) {
// We want to show the taken picture for a while, so we wait
// for at least 1.2 second before restarting the preview.
- long delay = 1200 - (
- System.currentTimeMillis() - mRawPictureCallbackTime);
+ long delay = 1200 - mPictureDisplayedToJpegCallbackTime;
if (delay < 0) {
restartPreview();
} else {
@@ -812,7 +834,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
mCameraDevice.setParameters(mParameters);
mCameraDevice.takePicture(mShutterCallback, mRawPictureCallback,
- new JpegPictureCallback(loc));
+ mPostViewPictureCallback, new JpegPictureCallback(loc));
mPreviewing = false;
}
@@ -822,6 +844,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
return;
}
mCaptureStartTime = System.currentTimeMillis();
+ mPostViewPictureCallbackTime = 0;
// Don't check the filesystem here, we can't afford the latency.
// Instead, check the cached value which was calculated when the
diff --git a/tests/src/com/android/camera/stress/CameraLatency.java b/tests/src/com/android/camera/stress/CameraLatency.java
index 221e7b1..0c5059f 100755
--- a/tests/src/com/android/camera/stress/CameraLatency.java
+++ b/tests/src/com/android/camera/stress/CameraLatency.java
@@ -40,14 +40,14 @@ public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> {
private long mTotalAutoFocusTime;
private long mTotalShutterLag;
- private long mTotalShutterAndRawPictureCallbackTime;
- private long mTotalJpegPictureCallbackTimeLag;
- private long mTotalRawPictureAndJpegPictureCallbackTime;
+ private long mTotalShutterToPictureDisplayedTime;
+ private long mTotalPictureDisplayedToJpegCallbackTime;
+ private long mTotalJpegCallbackToFirstFrameTime;
private long mAvgAutoFocusTime;
private long mAvgShutterLag = mTotalShutterLag;
- private long mAvgShutterAndRawPictureCallbackTime;
- private long mAveJpegPictureCallbackTimeLag;
- private long mAvgRawPictureAndJpegPictureCallbackTime;
+ private long mAvgShutterToPictureDisplayedTime;
+ private long mAvgPictureDisplayedToJpegCallbackTime;
+ private long mAvgJpegCallbackToFirstFrameTime;
public CameraLatency() {
super("com.android.camera", Camera.class);
@@ -78,11 +78,11 @@ public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> {
Camera c = getActivity();
mTotalAutoFocusTime += c.mAutoFocusTime;
mTotalShutterLag += c.mShutterLag;
- mTotalShutterAndRawPictureCallbackTime +=
- c.mShutterAndRawPictureCallbackTime;
- mTotalJpegPictureCallbackTimeLag += c.mJpegPictureCallbackTimeLag;
- mTotalRawPictureAndJpegPictureCallbackTime +=
- c.mRawPictureAndJpegPictureCallbackTime;
+ mTotalShutterToPictureDisplayedTime +=
+ c.mShutterToPictureDisplayedTime;
+ mTotalPictureDisplayedToJpegCallbackTime +=
+ c.mPictureDisplayedToJpegCallbackTime;
+ mTotalJpegCallbackToFirstFrameTime += c.mJpegCallbackToFirstFrameTime;
}
}
} catch (Exception e) {
@@ -96,12 +96,12 @@ public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> {
int numberofRun = TOTAL_NUMBER_OF_IMAGECAPTURE - 1;
mAvgAutoFocusTime = mTotalAutoFocusTime / numberofRun;
mAvgShutterLag = mTotalShutterLag / numberofRun;
- mAvgShutterAndRawPictureCallbackTime =
- mTotalShutterAndRawPictureCallbackTime / numberofRun;
- mAveJpegPictureCallbackTimeLag =
- mTotalJpegPictureCallbackTimeLag / numberofRun;
- mAvgRawPictureAndJpegPictureCallbackTime =
- mTotalRawPictureAndJpegPictureCallbackTime / numberofRun;
+ mAvgShutterToPictureDisplayedTime =
+ mTotalShutterToPictureDisplayedTime / numberofRun;
+ mAvgPictureDisplayedToJpegCallbackTime =
+ mTotalPictureDisplayedToJpegCallbackTime / numberofRun;
+ mAvgJpegCallbackToFirstFrameTime =
+ mTotalJpegCallbackToFirstFrameTime / numberofRun;
try {
FileWriter fstream = null;
@@ -111,11 +111,11 @@ public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> {
out.write("Number of loop: " + TOTAL_NUMBER_OF_IMAGECAPTURE + "\n");
out.write("Avg AutoFocus = " + mAvgAutoFocusTime + "\n");
out.write("Avg mShutterLag = " + mAvgShutterLag + "\n");
- out.write("Avg mShutterAndRawPictureCallbackTime = "
- + mAvgShutterAndRawPictureCallbackTime + "\n");
- out.write("Avg mJpegPictureCallbackTimeLag = " + mAveJpegPictureCallbackTimeLag + "\n");
- out.write("Avg mRawPictureAndJpegPictureCallbackTime = "
- + mAvgRawPictureAndJpegPictureCallbackTime + "\n");
+ out.write("Avg mShutterToPictureDisplayedTime = "
+ + mAvgShutterToPictureDisplayedTime + "\n");
+ out.write("Avg mPictureDisplayedToJpegCallbackTime = "
+ + mAvgPictureDisplayedToJpegCallbackTime + "\n");
+ out.write("Avg mJpegCallbackToFirstFrameTime = " + mAvgJpegCallbackToFirstFrameTime + "\n");
out.close();
fstream.close();
} catch (Exception e) {
@@ -124,11 +124,11 @@ public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> {
Log.v(TAG, "Avg AutoFocus = " + mAvgAutoFocusTime);
Log.v(TAG, "Avg mShutterLag = " + mAvgShutterLag);
- Log.v(TAG, "Avg mShutterAndRawPictureCallbackTime = "
- + mAvgShutterAndRawPictureCallbackTime);
- Log.v(TAG, "Avg mJpegPictureCallbackTimeLag = " + mAveJpegPictureCallbackTimeLag);
- Log.v(TAG, "Avg mRawPictureAndJpegPictureCallbackTime = "
- + mAvgRawPictureAndJpegPictureCallbackTime);
+ Log.v(TAG, "Avg mShutterToPictureDisplayedTime = "
+ + mAvgShutterToPictureDisplayedTime);
+ Log.v(TAG, "Avg mPictureDisplayedToJpegCallbackTime = "
+ + mAvgPictureDisplayedToJpegCallbackTime);
+ Log.v(TAG, "Avg mJpegCallbackToFirstFrameTime = " + mAvgJpegCallbackToFirstFrameTime);
assertTrue("testImageCapture", true);
}
}