Merge "Use calculated frame offset instead of gyroscope." into ics-mr0
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 8cc5816..a66a764 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -2078,7 +2078,7 @@
 
     private boolean switchToOtherMode(int mode) {
         if (isFinishing()) return false;
-        mImageSaver.waitDone();
+        if (mImageSaver != null) mImageSaver.waitDone();
         MenuHelper.gotoMode(mode, Camera.this);
         mHandler.removeMessages(FIRST_TIME_INIT);
         finish();
diff --git a/tests/src/com/android/camera/stress/SwitchPreview.java b/tests/src/com/android/camera/stress/SwitchPreview.java
index 6af915e..c5dd7c1 100755
--- a/tests/src/com/android/camera/stress/SwitchPreview.java
+++ b/tests/src/com/android/camera/stress/SwitchPreview.java
@@ -97,10 +97,13 @@
             for (int i=0; i< TOTAL_NUMBER_OF_SWITCHING; i++) {
                 Thread.sleep(WAIT_FOR_PREVIEW);
                 Intent intent = new Intent();
+                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                 intent.setClass(getInstrumentation().getTargetContext(),
                         VideoCamera.class);
                 getActivity().startActivity(intent);
                 Thread.sleep(WAIT_FOR_PREVIEW);
+                intent = new Intent();
+                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                 intent.setClass(getInstrumentation().getTargetContext(),
                         Camera.class);
                 getActivity().startActivity(intent);