From 23901e48e5b21a6798cc84a5acc32b47a15b3c1e Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Thu, 15 Jan 2015 15:58:19 +0800 Subject: SnapdragonCamera: Fix null pointer exception in SnapdragonCamera Null Pointer exception occurred in Camera during monkey test. Add null pointer check before use them. Change-Id: I992f6b8f8dc6b91947ec3e4d703b4e9b72996f67 CRs-Fixed: 780252 --- src/com/android/camera/PhotoMenu.java | 14 ++++++++++---- src/com/android/camera/PhotoModule.java | 13 ++++++++----- src/com/android/camera/PhotoUI.java | 11 ++++++++--- 3 files changed, 26 insertions(+), 12 deletions(-) (limited to 'src/com') diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java index 1aea279a3..f4a4b36ce 100644 --- a/src/com/android/camera/PhotoMenu.java +++ b/src/com/android/camera/PhotoMenu.java @@ -684,8 +684,11 @@ public class PhotoMenu extends MenuController @Override public void onClick(View v) { addSceneMode(); - View view = mUI.getPreviewMenuLayout().getChildAt(0); - animateSlideIn(view, previewMenuSize, false); + ViewGroup menuLayout = mUI.getPreviewMenuLayout(); + if (menuLayout != null) { + View view = menuLayout.getChildAt(0); + animateSlideIn(view, previewMenuSize, false); + } } }); } @@ -833,8 +836,11 @@ public class PhotoMenu extends MenuController @Override public void onClick(View v) { addFilterMode(); - View view = mUI.getPreviewMenuLayout().getChildAt(0); - animateSlideIn(view, previewMenuSize, false); + ViewGroup menuLayout = mUI.getPreviewMenuLayout(); + if (menuLayout != null) { + View view = mUI.getPreviewMenuLayout().getChildAt(0); + animateSlideIn(view, previewMenuSize, false); + } } }); } diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 1e238be80..93c093e4a 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -2097,10 +2097,12 @@ public class PhotoModule } //Need to disable focus for ZSL mode - if(mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) { - mFocusManager.setZslEnable(true); - } else { - mFocusManager.setZslEnable(false); + if (mFocusManager != null) { + if (mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) { + mFocusManager.setZslEnable(true); + } else { + mFocusManager.setZslEnable(false); + } } // If the user wants to do a snapshot while the previous one is still @@ -2108,7 +2110,8 @@ public class PhotoModule // one and re-start the preview. Snapshot in progress also includes the // state that autofocus is focusing and a picture will be taken when // focus callback arrives. - if ((mFocusManager.isFocusingSnapOnFinish() || mCameraState == SNAPSHOT_IN_PROGRESS) + if ((((mFocusManager != null) && mFocusManager.isFocusingSnapOnFinish()) + || mCameraState == SNAPSHOT_IN_PROGRESS) && !mIsImageCaptureIntent) { mSnapshotOnIdle = true; return; diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index b4e08c398..461fd67f3 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -553,7 +553,9 @@ public class PhotoUI implements PieListener, mMenuButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - mMenu.openFirstLevel(); + if(mMenu != null){ + mMenu.openFirstLevel(); + } } }); if (mController.isImageCaptureIntent()) { @@ -917,8 +919,11 @@ public class PhotoUI implements PieListener, } public boolean sendTouchToMenu(MotionEvent ev) { - View v = mMenuLayout.getChildAt(0); - return v.dispatchTouchEvent(ev); + if (mMenuLayout != null) { + View v = mMenuLayout.getChildAt(0); + return v.dispatchTouchEvent(ev); + } + return false; } public void dismissSceneModeMenu() { -- cgit v1.2.3