diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-08-25 10:24:50 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-08-25 17:52:26 +0800 |
commit | 58dadc3028b3af2e9895089e1b39ad1ab982ece2 (patch) | |
tree | c04fc5f6147619eee354020867dc3c9184c870ab /src | |
parent | 3a92e643ed83c0ecce072797259dd4fa11246b2b (diff) | |
download | LegacyCamera-58dadc3028b3af2e9895089e1b39ad1ab982ece2.zip LegacyCamera-58dadc3028b3af2e9895089e1b39ad1ab982ece2.tar.gz LegacyCamera-58dadc3028b3af2e9895089e1b39ad1ab982ece2.tar.bz2 |
Fix NPE in FocusManager.
bug:5210804
Change-Id: I39143a3c45d27db6dc2669e3a249945aafddc3c4
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 6 | ||||
-rw-r--r-- | src/com/android/camera/FocusManager.java | 17 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index aef4ac6..d682480 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -981,6 +981,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener, mPreferences = new ComboPreferences(this); CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal()); + mFocusManager = new FocusManager(mPreferences, + getString(R.string.pref_camera_focusmode_default)); mCameraId = CameraSettings.readPreferredCameraId(mPreferences); @@ -1008,9 +1010,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener, try { mCameraDevice = Util.openCamera(Camera.this, mCameraId); initializeCapabilities(); - mFocusManager = new FocusManager(mPreferences, - getString(R.string.pref_camera_focusmode_default), - mInitialParams); startPreview(); } catch (CameraHardwareException e) { mOpenCameraFail = true; @@ -2200,6 +2199,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private void initializeCapabilities() { mInitialParams = mCameraDevice.getParameters(); + mFocusManager.initializeParameters(mInitialParams); mFocusAreaSupported = (mInitialParams.getMaxNumFocusAreas() > 0 && isSupported(Parameters.FOCUS_MODE_AUTO, mInitialParams.getSupportedFocusModes())); diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java index 390b5d9..2c8b66f 100644 --- a/src/com/android/camera/FocusManager.java +++ b/src/com/android/camera/FocusManager.java @@ -38,7 +38,7 @@ import java.util.List; // A class that handles everything about focus in still picture mode. // This also handles the metering area because it is the same as focus area. public class FocusManager { - private static final String TAG = "Focus"; + private static final String TAG = "FocusManager"; private static final int RESET_TOUCH_FOCUS = 0; private static final int FOCUS_BEEP_VOLUME = 100; @@ -90,9 +90,14 @@ public class FocusManager { } } - public FocusManager(ComboPreferences preferences, String defaultFocusMode, Parameters parameters) { + public FocusManager(ComboPreferences preferences, String defaultFocusMode) { mPreferences = preferences; mDefaultFocusMode = defaultFocusMode; + mHandler = new MainHandler(); + } + + // This has to be initialized before initialize(). + public void initializeParameters(Parameters parameters) { mParameters = parameters; mFocusAreaSupported = (mParameters.getMaxNumFocusAreas() > 0 && isSupported(Parameters.FOCUS_MODE_AUTO, @@ -105,8 +110,11 @@ public class FocusManager { mPreviewFrame = previewFrame; mFaceView = faceView; mListener = listener; - mHandler = new MainHandler(); - mInitialized = true; + if (mParameters != null) { + mInitialized = true; + } else { + Log.e(TAG, "mParameters is not initialized."); + } } public void doFocus(boolean pressed) { @@ -322,6 +330,7 @@ public class FocusManager { } } + // This can only be called after mParameters is initialized. public String getFocusMode() { if (mOverrideFocusMode != null) return mOverrideFocusMode; |