Synchronize CaptureModule camera open/close operations

This fixes a race condition in which CaptureModule gets a pause()
immediately after it is asked to open the camera.  pause() MUST
wait/block to close the camera to ensure that we can later open it (a
fast open()->pause() sequence is reproducible via the lockscreen under
certain cases when we get a rapid onResume()->onPause()->onResume),
so this adds the necessary threading logic to wait, if necessary,
for the camera to finish opening so that it can be closed.

Bug: 17642065
Change-Id: Ic88bd32fc5acc2b333de367019085a8cd539c5a5
5 files changed