Fix inconsistant results for some cts tests.

This patch fixes any cts test that uses the camera's startPreview function
without the proper timing delay before stopping the preview. When we do a
startPreview(), it will start a WorkerThread. If that thread don't get a
chance to run, then when we try to stop the thread, the stop can fail and
cause the current test to fail (thread not running) or subsequent tests
to fail (thread already started).

The following tests are known to fail randomly due to this timing problem:
android.hardware.cts.CameraTest#testDisplayOrientation
android.hardware.cts.CameraTest#testGetParameterDuringFocus
android.hardware.cts.CameraTest#testJpegCallbackStartPreview
android.hardware.cts.CameraTest#testRecordingHint
android.hardware.cts.CameraTest#testLockUnlock
android.hardware.cts.CameraTest#testPreviewCallback
android.hardware.cts.CameraTest#testSetOneShotPreviewCallback
android.media.cts.MediaRandomTest#testRecorderRandomAction

Change-Id: Ifc20d93bc02cdc49161f54c083a32138574a8d39
2 files changed