Camera: Add proper support for ListPreference

* The original code handled only IconListPreference, resulting in many issues
* Unlike AOSP, we use a lot of ListPreference menus, so we need to properly handle them
* Avoid code duplication in PhotoMenu & VideoMenu
* Correctly disable options when they should be disabled
* Correct MoreSettingPopup handling in both photo & video settings

Change-Id: I09d7280ca58af4e4fe81635980f35d394b114f2a
Camera: open Camera and start Preview in a seperate thread.

Start openCamera and start preview in a separate thread so that
UI initialization and preview can run parallely. This is to
improve camera cold start latency.

Change-Id: I57af45bc90a4db1630c73449d543c3ff0992e55c
Camera: Disable HDR when scene mode is other than auto

- HDR option is enabled even when scene mode is not auto.
  Due to this preview and snapshot are still remain in previous
  scene mode after enabling HDR.

- Fix is to disable the HDR when scene mode is other than auto.

Change-Id: Icec96816a7ed6f3daacc8b79841dee5db6b4b04a
CRs-Fixed: 648847
Camera2: Still popup tips when change scene to other after turn off HDR

The toast popup or not depend on the value of hdr and scene mode,
but now the value mHdrOn status is not uniform with the actual hdr
value, which lead to popup toast incorrect.

Get the value of scene mode or hdr from the preference directly rather
than a new variable. So the mHdrOn is not used and delete it.

CRs-Fixed: 674521

Change-Id: I1c6926e0ba295e9869109b7412a7413323d3bd1c
Camera2: fix start preview when hdr is on issue

when we have already set hdr on and do not set off, we don't need
to set it to scene mode to auto every time. This will make the camerea
to start preview again, which will make the app freeze for a while.

Change-Id: Ica77106b88056e289cd298eda4ccc5c3f4f6ab59
CRs-Fixed: 679200
Camera2: Do not restart preview to update flip params during orientation change.

When there was a orientation change flip paramter had to be changed.
Currently all parameters are set again and preview is being restarted.
so preview will not be smooth when user rotae the device.

This change makes sure only necessary params are updated and
preview will not be restarted.

CRs-Fixed: 710129

Change-Id: I564431ef8cedaf68c9d12e2a84a3a430c845ab6d
Camera2: fix a camera status bug

After a picture is taken for MMS app, the preview has been stopped in
onPictureTaken() but the camera state is subsequently set to IDLE in
ZSL mode. Add a check before assignment.

Change-Id: I0610a58dbccffdba4b94140d74942c2ff60c7882
CRs-Fixed: 675176
Camera2: Fix video duration is wrong issue

When mMediaRecorderPausing is true, video duration
is equal to mRecordingTotalTime, which can fix video
duration is wrong issue if use pause/resume.

Change-Id: I71d41414bba11564cfe84166fbc18608636a73d1
Camera2: fix camera crash when mPieRender is null

The autofocus maybe called before onCameraOpened, and mPieRender is
not initialize which lead to camera crash.

Check null when show focus ui.

CRs-Fixed: 712850

Change-Id: If3d51c8ea31f4a755e26fe4730e85428373e6446
Camera2: Don't report incorrect supported picture formats

If camera HAL does not return valid picture formats do not show wrong defaults

Currently it falls back to jpeg and raw to choose for the user. All our devices
 which do not have a proper
return of picture format only support jpg. So remove the entry to choose in
 this case completely

Change-Id: Ib4e4094ba0a57e7751f6568f6ec3c3f1dfc1ffb8
Camera2: fix unresponsive shutter button after failure

Shutter button is disabled during capture(). It's only re-enabled in
onPicutreTaken() callback. If camera is switched just before counting
down finishes, picture taking may fail and shutter button is left
disabled. Enabling shutter button in onPreviewStarted() fixes the
problem.

Change-Id: I92c644e9a0d283f9ab0269b85586f27e0f4eeb1b
CRs-Fixed: 667311
camera: Override color effect when scene mode is active

Change-Id: Ia27ed59f3f27e9c867cbb4c8823abb78b0035047
Camera2: Fix ANR when switching camera during AF

- Check that 'mCameraDevice' is valid at beginning of
  setCameraParameters(). This will avoid null pointer
  exceptions at some cases, when setCameraParameters()
  is called by focus manager after closing camera.

CRs-Fixed: 668405
Change-Id: Iff4b81e725db6db11cdc205512b0fec1f71f333d
Camera: Change video capture duration with HFR

While capturing a video with HFR, duration is getting stored
properly in metadata but not in media database. While checking
details, duration is showing actual captured duration, not the
playback duration. After rebooting the phone, then media table
is getting updated with proper duration.

Fix made: After capture, change duration value as per user selected
HFR option.

CRs-Fixed: 627354

Change-Id: Ifb7c607e3545c4d2a2e0b1b7666cb0567640d416
Camera: Check if codec supports HFR resolution/fps.

Some codecs can have limitation on the max HFR fps and video
size combination. So, query the video encoder capabilites first
and report error if codec doesnt support the combination.

Change-Id: Ic2032176067a6f92d1363471d1a767d5ef589591
Camera: Block DIS and Timelapse for HFR

DIS and Timelapse is not supported for HFR scenario.
If user'll start recording with timelapse or DIS with HFR
then crash observed from lower layer.

Fix Made: User'll be notified that HFR/HSR selection is not allowed
for TimeLapse and/ DIS mode. After that, HFR selection will be set to
off and the option will be disabled. It'll not be vice versa as
DIS/TimeLapse has higher priority than HFR for their existance in
primary popup rather than being in secondary.

[mikeioannina]: removed HSR code

Change-Id: I42ed3d3d20727ddda1b15c21b3ba85c8c41a82ef
CRs-Fixed: 627373, 627362
Camera: Disable DIS option for unsupported resolution

DIS will not work for unsupported resolution.
If user'll start recording with DIS alongwith 720p resolution
using front camera, then it'll crash.

Fix: Block in UI, so that user'll not be able to select DIS with
unsupported resolution after intimating through toasts.

Change-Id: Ie788d456a7b15061f16a44ca34ccd3d1e6d90071
CRs-Fixed: 644268
Camera: Block HFR option for Video HDR

Video HDR can’t work with HFR and that caused AEC behaviour change.

Fix Made: User'll be notified that HFR/HSR selection is not allowed
for HDR mode. After that, HFR selection will be set to off and the
option will be disabled. It'll not be vice versa as HDR has higher
priority than HFR.

[mikeioannina]: Removed HSR code

Change-Id: I4b0f8362667a53e46a83223cab77b7248e1410e2
CRs-Fixed: 652078
Camera2: update the flash icon when set HDR on

When HDR is on the flash mode should be set to off. And
the icon should be show as off too

Change-Id: I2cca985694e8a5a8058d6bf5467d5375514acfab
CRs-fixed: 645595
Camera2: fix The flashlight still is on after set scene mode not auto

If we set flash mode is on when scene mode is auto, the flash mode won't
be reset when change to other scenemode and still is on.

Set the flash mode is auto when scene mode is not auto.

CRs-Fixed: 678466

Change-Id: If3874c03dc70297326b6cd7dcceb1f4efde85956