Merge "Camera2: Fix uninitialized parameters." into jb-mr1-dev
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 3a2dbe2..155a0b8 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -91,10 +91,6 @@
     if (rc)
         return;
 
-    property_get("ro.camera.sound.forced", value, "0");
-    forced_val = strtol(value, NULL, 0);
-    mpAudioPolicy->set_can_mute_enforced_audible(mpAudioPolicy, !forced_val);
-
     ALOGI("Loaded audio policy from %s (%s)", module->name, module->id);
 
     // load audio pre processing modules
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index e073e39..7a6e344 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -959,6 +959,21 @@
             return INVALID_OPERATION;
         }
 
+        /**
+          * If the camera does not support auto-focus, it is a no-op and
+          * onAutoFocus(boolean, Camera) callback will be called immediately
+          * with a fake value of success set to true.
+          */
+        if (l.mParameters.focusMode == Parameters::FOCUS_MODE_FIXED) {
+            SharedCameraClient::Lock l(mSharedCameraClient);
+            if (l.mCameraClient != 0) {
+                l.mCameraClient->notifyCallback(CAMERA_MSG_FOCUS,
+                    /*success*/1, 0);
+            }
+
+            return OK;
+        }
+
         if (l.mParameters.quirks.triggerAfWithAuto &&
                 l.mParameters.sceneMode != ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED &&
                 l.mParameters.focusMode != Parameters::FOCUS_MODE_AUTO) {
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
index 5156539..fe4abc0 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -40,6 +40,7 @@
         mNewAEState(false),
         mNewFrameReceived(false),
         mNewCaptureReceived(false),
+        mShutterNotified(false),
         mClient(client),
         mCaptureState(IDLE),
         mTriggerId(0),
@@ -308,6 +309,7 @@
     } else {
         nextState = STANDARD_START;
     }
+    mShutterNotified = false;
 
     return nextState;
 }
@@ -342,7 +344,7 @@
     SharedParameters::Lock l(client->getParameters());
     /* warning: this also locks a SharedCameraClient */
     shutterNotifyLocked(l.mParameters, client);
-
+    mShutterNotified = true;
     mTimeoutCount = kMaxTimeoutsForCaptureEnd;
     return STANDARD_CAPTURE_WAIT;
 }
@@ -474,9 +476,6 @@
         return DONE;
     }
 
-    /* warning: this also locks a SharedCameraClient */
-    shutterNotifyLocked(l.mParameters, client);
-
     mTimeoutCount = kMaxTimeoutsForCaptureEnd;
     return STANDARD_CAPTURE_WAIT;
 }
@@ -493,7 +492,13 @@
             break;
         }
     }
-    while (!mNewCaptureReceived) {
+    if (mNewFrameReceived && !mShutterNotified) {
+        SharedParameters::Lock l(client->getParameters());
+        /* warning: this also locks a SharedCameraClient */
+        shutterNotifyLocked(l.mParameters, client);
+        mShutterNotified = true;
+    }
+    while (mNewFrameReceived && !mNewCaptureReceived) {
         res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration);
         if (res == TIMED_OUT) {
             mTimeoutCount--;
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.h b/services/camera/libcameraservice/camera2/CaptureSequencer.h
index 8df6d95..4cde9c8 100644
--- a/services/camera/libcameraservice/camera2/CaptureSequencer.h
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.h
@@ -94,6 +94,8 @@
     sp<MemoryBase> mCaptureBuffer;
     Condition mNewCaptureSignal;
 
+    bool mShutterNotified;
+
     /**
      * Internal to CaptureSequencer
      */