Camera2: fix a crash in taking picture

takePicture calls should not overlap, otherwise a fatal exception will
occur. Check and modify camera state before the call to prevent such
crash.

Change-Id: I5316f0d389631c3e4b5f92a8eb81e11a5af804a6