summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher R. Palmer <crpalmer@gmail.com>2014-11-11 05:59:16 -0500
committerChristopher R. Palmer <crpalmer@gmail.com>2014-11-14 05:48:31 -0500
commite95ccbc2275afdff17ed106cbc0266de58aab24e (patch)
tree512fb746a98c4a97f1f233968f4fdeb2db4cb8e4
parent7ae0cf0b9a2d0f41889599806d8a977a43c8362a (diff)
downloadandroid_packages_apps_Camera2-e95ccbc2275afdff17ed106cbc0266de58aab24e.tar.gz
android_packages_apps_Camera2-e95ccbc2275afdff17ed106cbc0266de58aab24e.tar.bz2
android_packages_apps_Camera2-e95ccbc2275afdff17ed106cbc0266de58aab24e.zip
Camera2: Allow devices to opt-out of threaded camera startup
On at least the current Exynos based devices, the vendor's HAL appears to be unable to handle the threaded startup. Since we cannot easily fix their HAL, allow these devices to opt out of the faster camera startup. Change-Id: I8d1935eb69bb8ba1396b59d92993062637654258
-rw-r--r--res/values/config.xml4
-rw-r--r--src/com/android/camera/PhotoModule.java41
2 files changed, 33 insertions, 12 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index 9bb3b8b73..fde705275 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -43,4 +43,8 @@
<bool name="enableHDRWithZSL">false</bool>
<!-- Enable histogram support -->
<bool name="enableHistogram">false</bool>
+
+ <!-- Controls whether or not the HAL allows a multi-threaded
+ camera startup -->
+ <bool name="enableThreadedCameraStartup">true</bool>
</resources>
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 5a1013b63..ababaf291 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -237,6 +237,28 @@ public class PhotoModule
}
private OpenCameraThread mOpenCameraThread = null;
+ private boolean mEnableThreadedCameraStartup = true;
+
+ private void startOpenCameraThread() {
+ mOpenCameraThread = new OpenCameraThread();
+ if (mEnableThreadedCameraStartup) {
+ mOpenCameraThread.start();
+ } else {
+ mOpenCameraThread.run();
+ }
+ }
+
+ private void stopOpenCameraThread() {
+ if (mOpenCameraThread != null && mEnableThreadedCameraStartup) {
+ try {
+ mOpenCameraThread.join();
+ } catch (InterruptedException ex) {
+ // ignore
+ }
+ }
+ mOpenCameraThread = null;
+ }
+
/**
* An unpublished intent flag requesting to return as soon as capturing
* is completed.
@@ -520,9 +542,11 @@ public class PhotoModule
// Max brightness
mActivity.initMaxBrightness(mPreferences);
+ mEnableThreadedCameraStartup = mActivity.getResources().getBoolean(
+ R.bool.enableThreadedCameraStartup);
+
if (mOpenCameraThread == null && !mActivity.mIsModuleSwitchInProgress) {
- mOpenCameraThread = new OpenCameraThread();
- mOpenCameraThread.start();
+ startOpenCameraThread();
}
initializeControlByIntent();
mQuickCapture = mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false);
@@ -1886,8 +1910,7 @@ public class PhotoModule
if (mOpenCameraFail || mCameraDisabled) return;
if (mOpenCameraThread == null) {
- mOpenCameraThread = new OpenCameraThread();
- mOpenCameraThread.start();
+ startOpenCameraThread();
}
mJpegPictureCallbackTime = 0;
@@ -1950,14 +1973,8 @@ public class PhotoModule
Log.v(TAG, "On pause.");
mUI.showPreviewCover();
- try {
- if (mOpenCameraThread != null) {
- mOpenCameraThread.join();
- }
- } catch (InterruptedException ex) {
- // ignore
- }
- mOpenCameraThread = null;
+ stopOpenCameraThread();
+
// Reset the focus first. Camera CTS does not guarantee that
// cancelAutoFocus is allowed after preview stops.
if (mCameraDevice != null && mCameraState != PREVIEW_STOPPED) {