From 93aeb670e817986817ce585aa6deaf1c4945dabe Mon Sep 17 00:00:00 2001 From: Jay Wang Date: Thu, 15 Sep 2016 12:44:03 -0700 Subject: SnapdragonCamera: Use constant obj when queueing and removing msg Use a constant token obj when tagging messages to be queued and removed from handler. CRs-Fixed: 1068401 Change-Id: I2b1a653ea0ca1df8f9502ed4a09da53be61b62e0 --- src/com/android/camera/CaptureModule.java | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/com/android/camera/CaptureModule.java') diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index c914b8602..95c241d0c 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -483,7 +483,7 @@ public class CaptureModule implements CameraModule, PhotoController, mCameraOpened[id] = true; if (isBackCamera() && getCameraMode() == DUAL_MODE && id == BAYER_ID) { - Message msg = mCameraHandler.obtainMessage(OPEN_CAMERA, MONO_ID); + Message msg = mCameraHandler.obtainMessage(OPEN_CAMERA, MONO_ID, 0); mCameraHandler.sendMessage(msg); } else { mCamerasOpened = true; @@ -1007,7 +1007,7 @@ public class CaptureModule implements CameraModule, PhotoController, mTakingPicture[id] = true; if (mState[id] == STATE_WAITING_TOUCH_FOCUS) { - mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, id); + mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[id]); mState[id] = STATE_WAITING_AF_LOCK; return; } @@ -1045,7 +1045,7 @@ public class CaptureModule implements CameraModule, PhotoController, mState[id] = STATE_WAITING_TOUCH_FOCUS; mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler); setAFModeToPreview(id, mControlAFMode); - Message message = mCameraHandler.obtainMessage(CANCEL_TOUCH_FOCUS, id); + Message message = mCameraHandler.obtainMessage(CANCEL_TOUCH_FOCUS, mCameraId[id]); mCameraHandler.sendMessageDelayed(message, CANCEL_TOUCH_FOCUS_DELAY); } catch (CameraAccessException e) { e.printStackTrace(); @@ -1875,17 +1875,16 @@ public class CaptureModule implements CameraModule, PhotoController, switch (getCameraMode()) { case DUAL_MODE: case BAYER_MODE: - msg.obj = BAYER_ID; + msg.arg1 = BAYER_ID; mCameraHandler.sendMessage(msg); break; case MONO_MODE: - msg.what = OPEN_CAMERA; - msg.obj = MONO_ID; + msg.arg1 = MONO_ID; mCameraHandler.sendMessage(msg); break; } } else { - msg.obj = FRONT_ID; + msg.arg1 = FRONT_ID; mCameraHandler.sendMessage(msg); } if (!mFirstTimeInitialized) { @@ -2316,7 +2315,7 @@ public class CaptureModule implements CameraModule, PhotoController, mMediaRecorderPausing = false; mUI.hideUIwhileRecording(); mUI.clearFocus(); - mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, cameraId); + mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[cameraId]); mState[cameraId] = STATE_PREVIEW; mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE; closePreviewSession(); @@ -3147,10 +3146,19 @@ public class CaptureModule implements CameraModule, PhotoController, int height = p.y; mAFRegions[id] = afaeRectangle(x, y, width, height, 1f, mCropRegion[id]); mAERegions[id] = afaeRectangle(x, y, width, height, 1.5f, mCropRegion[id]); - mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, id); + mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[id]); autoFocusTrigger(id); } + private void cancelTouchFocus(int id) { + if(mPaused) + return; + + mState[id] = STATE_PREVIEW; + mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE; + setAFModeToPreview(id, mControlAFMode); + } + private MeteringRectangle[] afaeRectangle(float x, float y, int width, int height, float multiple, Rect cropRegion) { int side = (int) (Math.max(width, height) / 8 * multiple); @@ -3447,15 +3455,13 @@ public class CaptureModule implements CameraModule, PhotoController, @Override public void handleMessage(Message msg) { - int id = (int) msg.obj; + int id = msg.arg1; switch (msg.what) { case OPEN_CAMERA: openCamera(id); break; case CANCEL_TOUCH_FOCUS: - mState[id] = STATE_PREVIEW; - mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE; - setAFModeToPreview(id, mControlAFMode); + cancelTouchFocus(id); break; } } -- cgit v1.2.3