Camcorder: Switch video torch when preview focused

- Currently, video torch switching is not determined
  properly. When user enables and disables flash mode
  checkbox, nothing happens. Also, if video torch
  is enabled and switching to Camera and back to
  Camcorder mode, torch doesn't lights up.

- Adding a local variable mPreviewFocused to track
  the preview window focus state should fix the issue.

Change-Id: Ia134b86885eda1ad50d510e67e5595a391326d10
CRs-fixed: 567295

Conflicts:
	src/com/android/camera/VideoModule.java
Camera: Don't do cancel_af till all CBs are received in burst shot

Doing cancel_af in the first jpeg CB while
burst shot is going on, is changing the
camera state to IDLE and allowing next
takePicture() which is resulting in crash
as this call reaches HAL when camera is in
picture taking state.

Change-Id: Idd146060a73161bcc30c34756fb53662bb1f0902
CRs-Fixed: 593352

Conflicts:
	src/com/android/camera/PhotoModule.java
Camera2 : Reset mSnapshotInProgress if recording stopped.

If recording stops while snapshot is in progress, we might not get
jpeg callback because cameraservice will disable picture related
messages. Hence reset mSnapshotInProgress flag so that we can take
liveshots in the next recording session.

Change-Id: I6a639eb0b9444e4915786c65f64d3b95b064267c
CRs-Fixed: 588698
Camera: Dont reset camera state while capture is in progress.

While capture is in progress and if we get autofocus event,
currently we reset the camera state to IDLE blindly. This is
resulting in app exception because it will trigger another
takepicture and lower layers will return error.

( cherrypicked from commit 1bed537bb0848b6a1f64f9eb245b1c256999ebad )

Change-Id: Ia595dbad246759870371b749c0aa2def221560c5
CRs-Fixed: 550417
Camera2: override Saturation&Contrast item when enable scence mode

When HDR or any other scene mode is enabled, should disable the
saturation and contrast items into gray.

( cherrypicked from commit aceeee3ef5812836265127ed784adb4ab5ed57fb )

Change-Id: Ia4e20e0ee2f80661c8b72bf81aeee6fa96dcdf1f
CRs-Fixed: 526617

Conflicts:
	src/com/android/camera/PhotoModule.java
Camera2:stop recording from camcorder app in case of error

This change makes sure that stopvideoRecording is called
for all error returns to the video recording app.

( cherrypicked from commit 9d65272083d0a78ca4adefbffc38f98b44cfa489 )

Change-Id: I88c4ac92f065e5008c16a7697a84301e1ff5e98f
CRs-Fixed: 517351
Camera2: Fix concurrency issues with camera messages

Without this, multiple threads are
trying to access same data and
resulting in crash.

( cherrypicked from commit d11040c561e9add30768947aa93235ff08de03b1 )

Change-Id: Ib09950d6640afcd7962cba9ea5385d778f022abe
CRs-Fixed: 542706
Camera2: Check mCameradevice before setting skinToneEnhancement

Null pointer exception in app is observed when we open camera
and immediately press home/back button. This is because
mCameradevice will be null by the time handler thread gets a
message to setskinToneEnhancement parameter.

( cherrypicked from commit 06fee777df529fa53ac5c5305e7324ad1baf085d )

Change-Id: I7f216a11a29b6b205be4c2d0ca8f1c346284c294
CRs-Fixed: 547522
Camera2: Synchronize access to camera parameters

- Concurrent access between the main handler
  thread and the camera start-up thread w.r.t.
  'mParameters' is possible. This change will
  synchronize the two threads in order to avoid
  any exceptions.

( cherrypicked from commit e988411c441410f270fe0b98dfd0d9b1f033503f )

Change-Id: I290452723b3687eba5240f451cc94aef175a9fc4
CRs-Fixed: 539634

Conflicts:
	src/com/android/camera/PhotoModule.java
Camera: Prevent callling of resize  before camera is initialized

Prevent callling of resizeForPreviewAspectRatio
before camera is initialized

( cherrypicked from commit 57698f01193a75948505d0d6c098364e155c6a5b )

Change-Id: I400dbf30c30f5e2a458eac8fe05449ee055cb0f4
CRs-Fixed: 598600
Camera: Add checker for null pointer exception during camera release

In current code, handler will still try to execute command even
camera is closed, so add null point checker to skip these commands

( cherrypicked from commit 63ae64c56b00f44956502822a0ddb96307ae7270 )

Change-Id: I71c30a5293364e084de650e92d9d0926e7e3d7c1
CRs-Fixed: 598600
Update settings pref values when BSM is not auto.

When BSM mode is set to a value other than auto, flash mode, white
balance and few more settings will not be based on user preferred
settings. So mParameter object will have default values. Updating
those values in the list will over write the preferences.
To preserve settings from preferences, we need to pass the same
values.

CRs-Fixed: 573584
Change-Id: Ic62dc537250468f189374fae9a897ee46d40e3a1

Conflicts:
	src/com/android/camera/PhotoModule.java
Camera2: Added pause button in Camcorder

- Added pause button in camcorder app.so that user pause
  recording and resume later which results in a single
  recorded clip.
CRs-Fixed: 587051

Change-Id: I2a7d8af7fcea74fe8af62c44119c3c1fa0c13e85

Conflicts:
	res/layout/video_module.xml
	src/com/android/camera/VideoUI.java
Camera: Add a filter to remove unsupported hfr modes in camcorder

Some sensors don't support some hfr modes, so in camera setting,
a filter should be used to block unnecessary menu items.

( cherrypicked from commit a7536c35e22148ee1def337d36fce0682a347c92 )

Change-Id: I5b243e59c99f4daaa36022867d19782b6e2395eb
CRs-Fixed: 598600

Conflicts:
	src/com/android/camera/CameraSettings.java
Camera2: Calculate UI aspect ratio based on preview size

- This reverts change If4047860.

- Simply using preview size instead of picture size
  at all to calculate the UI aspect ratio,
  avoiding tricky overwriting aspect ratio.

- Will fix issues when surface texture transform
  is calculated based sometimes on preview size
  ratio and sometimes on picture size ratio.

CRs-Fixed: 601495
Change-Id: I8e054c9eaafc9fb54dac2bff2c67e39f0a1fe64c

Conflicts:
	src/com/android/camera/PhotoModule.java
	src/com/android/camera/PhotoUI.java
camera: fix camera crash in hfr

- When the maximum supported sizes of 60/90/120 are different, camera
  will crash when set hfr size to the maximum supported size while the
  current hfr mode doesn't support.
- Fix is to use the supported maximum size of the HFR only when the
  specified maximum size is not supported by the current HFR mode.

( cherrypicked from commit 494783c6dc29e76adbc7a714062c6739b785ee23 )

Change-Id: Ia74949e5f97d02b22ad817ac7068b5a676004f3a
CRs-Fixed: 527339
Camera2: Crowdin fixes

Change-Id: I7ad3baeb8645aaba75643886b23ff5a780bbd867

Conflicts:
	res/values-af/cm_strings.xml
	res/values-da/cm_strings.xml
	res/values-lt/cm_strings.xml
	res/values-nl/cm_strings.xml
	res/values-ru/cm_strings.xml