OSDN Git Service

Add proper support for canceling sessions.
[android-x86/packages-apps-Camera2.git] / src / com / android / camera / captureintent / state / StateReadyForCapture.java
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.android.camera.captureintent.state;
18
19 import android.graphics.Bitmap;
20 import android.graphics.Matrix;
21 import android.graphics.Point;
22 import android.graphics.PointF;
23 import android.graphics.RectF;
24 import android.media.MediaActionSound;
25 import android.net.Uri;
26
27 import com.android.camera.async.RefCountBase;
28 import com.android.camera.captureintent.CaptureIntentConfig;
29 import com.android.camera.captureintent.CaptureIntentModuleUI;
30 import com.android.camera.captureintent.PictureDecoder;
31 import com.android.camera.captureintent.event.EventCameraBusy;
32 import com.android.camera.captureintent.event.EventCameraQuickExpose;
33 import com.android.camera.captureintent.event.EventCameraReady;
34 import com.android.camera.captureintent.event.EventFastPictureBitmapAvailable;
35 import com.android.camera.captureintent.event.EventOnSurfaceTextureUpdated;
36 import com.android.camera.captureintent.event.EventOnTextureViewLayoutChanged;
37 import com.android.camera.captureintent.event.EventPause;
38 import com.android.camera.captureintent.event.EventPictureCompressed;
39 import com.android.camera.captureintent.event.EventPictureDecoded;
40 import com.android.camera.captureintent.event.EventTapOnCancelShutterButton;
41 import com.android.camera.captureintent.event.EventTapOnPreview;
42 import com.android.camera.captureintent.event.EventTapOnShutterButton;
43 import com.android.camera.captureintent.event.EventTapOnSwitchCameraButton;
44 import com.android.camera.captureintent.event.EventTimerCountDownToZero;
45 import com.android.camera.captureintent.event.EventZoomRatioChanged;
46 import com.android.camera.captureintent.resource.ResourceCaptureTools;
47 import com.android.camera.captureintent.resource.ResourceCaptureToolsImpl;
48 import com.android.camera.captureintent.resource.ResourceConstructed;
49 import com.android.camera.captureintent.resource.ResourceOpenedCamera;
50 import com.android.camera.captureintent.resource.ResourceSurfaceTexture;
51 import com.android.camera.captureintent.stateful.EventHandler;
52 import com.android.camera.captureintent.stateful.State;
53 import com.android.camera.captureintent.stateful.StateImpl;
54 import com.android.camera.debug.Log;
55 import com.android.camera.device.CameraId;
56 import com.android.camera.one.OneCamera;
57 import com.android.camera.one.OneCameraAccessException;
58 import com.android.camera.one.OneCameraCharacteristics;
59 import com.android.camera.session.CaptureSession;
60 import com.android.camera.session.CaptureSessionManager;
61 import com.android.camera.settings.Keys;
62 import com.android.camera.settings.SettingsManager;
63 import com.android.camera.ui.CountDownView;
64 import com.android.camera.ui.TouchCoordinate;
65 import com.android.camera.ui.focus.FocusController;
66 import com.google.common.base.Optional;
67
68 /**
69  * Represents a state that allows users to take a picture. The capture UI
70  * should be presented in this state so users can perform actions:
71  * 1. tap on shutter button to take a picture.
72  * 2. tap on viewfinder to focus.
73  * 3. switch between front and back camera.
74  */
75 public final class StateReadyForCapture extends StateImpl {
76     private static final Log.Tag TAG = new Log.Tag("StateReadyCap");
77
78     private final RefCountBase<ResourceCaptureTools> mResourceCaptureTools;
79
80     private boolean mShouldUpdateTransformOnNextSurfaceTextureUpdate;
81     private boolean mIsCountingDown;
82     private boolean mIsTakingPicture;
83     private boolean mIsDecodingPicture;
84
85     public static StateReadyForCapture from(
86             StateStartingPreview startingPreview,
87             RefCountBase<ResourceConstructed> resourceConstructed,
88             RefCountBase<ResourceSurfaceTexture> resourceSurfaceTexture,
89             RefCountBase<ResourceOpenedCamera> resourceOpenedCamera) {
90         return new StateReadyForCapture(
91                 startingPreview, resourceConstructed, resourceSurfaceTexture, resourceOpenedCamera);
92     }
93
94     public static StateReadyForCapture from(
95             StateReviewingPicture reviewingPicture,
96             RefCountBase<ResourceCaptureTools> resourceCaptureTools) {
97         return new StateReadyForCapture(reviewingPicture, resourceCaptureTools);
98     }
99
100     private StateReadyForCapture(
101             State previousState,
102             RefCountBase<ResourceConstructed> resourceConstructed,
103             RefCountBase<ResourceSurfaceTexture> resourceSurfaceTexture,
104             RefCountBase<ResourceOpenedCamera> resourceOpenedCamera) {
105         super(previousState);
106         mResourceCaptureTools = ResourceCaptureToolsImpl.create(
107                 resourceConstructed, resourceSurfaceTexture, resourceOpenedCamera);
108         mIsCountingDown = false;
109         mIsTakingPicture = false;
110         mIsDecodingPicture = false;
111         mShouldUpdateTransformOnNextSurfaceTextureUpdate = true;
112         registerEventHandlers();
113     }
114
115     private StateReadyForCapture(
116             State previousState,
117             RefCountBase<ResourceCaptureTools> resourceCaptureTools) {
118         super(previousState);
119         mResourceCaptureTools = resourceCaptureTools;
120         mResourceCaptureTools.addRef();  // Will be balanced in onLeave().
121         mIsCountingDown = false;
122         mIsTakingPicture = false;
123         mIsDecodingPicture = false;
124         mShouldUpdateTransformOnNextSurfaceTextureUpdate = true;
125         registerEventHandlers();
126     }
127
128     private void registerEventHandlers() {
129         /** Handles EventPause. */
130         EventHandler<EventPause> pauseHandler = new EventHandler<EventPause>() {
131             @Override
132             public Optional<State> processEvent(EventPause event) {
133                 return Optional.of((State) StateBackgroundWithSurfaceTexture.from(
134                         StateReadyForCapture.this,
135                         mResourceCaptureTools.get().getResourceConstructed(),
136                         mResourceCaptureTools.get().getResourceSurfaceTexture()));
137             }
138         };
139         setEventHandler(EventPause.class, pauseHandler);
140
141         /** Handles EventOnSurfaceTextureUpdated. */
142         EventHandler<EventOnSurfaceTextureUpdated> onSurfaceTextureUpdatedHandler =
143                 new EventHandler<EventOnSurfaceTextureUpdated>() {
144                     @Override
145                     public Optional<State> processEvent(EventOnSurfaceTextureUpdated event) {
146                         if (mShouldUpdateTransformOnNextSurfaceTextureUpdate) {
147                             mShouldUpdateTransformOnNextSurfaceTextureUpdate = false;
148                             mResourceCaptureTools.get().getResourceSurfaceTexture().get()
149                                     .updatePreviewTransform();
150                             removeEventHandler(EventOnSurfaceTextureUpdated.class);
151                         }
152                         return NO_CHANGE;
153                     }
154                 };
155         setEventHandler(EventOnSurfaceTextureUpdated.class, onSurfaceTextureUpdatedHandler);
156
157         /** Handles EventOnTextureViewLayoutChanged. */
158         EventHandler<EventOnTextureViewLayoutChanged> onTextureViewLayoutChangedHandler =
159                 new EventHandler<EventOnTextureViewLayoutChanged>() {
160                     @Override
161                     public Optional<State> processEvent(EventOnTextureViewLayoutChanged event) {
162                         mResourceCaptureTools.get().getResourceSurfaceTexture().get()
163                                 .setPreviewLayoutSize(event.getLayoutSize());
164                         return NO_CHANGE;
165                     }
166                 };
167         setEventHandler(
168                 EventOnTextureViewLayoutChanged.class, onTextureViewLayoutChangedHandler);
169
170         /** Handles EventCameraBusy. */
171         setEventHandler(
172                 EventCameraBusy.class, mEventCameraBusyHandler);
173
174         /** Handles EventCameraReady. */
175         setEventHandler(
176                 EventCameraReady.class, mEventCameraReadyHandler);
177
178         /** Handles EventTapOnShutterButton. */
179         EventHandler<EventTapOnShutterButton> tapOnShutterButtonHandler =
180                 new EventHandler<EventTapOnShutterButton>() {
181                     @Override
182                     public Optional<State> processEvent(final EventTapOnShutterButton event) {
183                         final int countDownDuration =
184                                 mResourceCaptureTools.get().getResourceConstructed().get()
185                                         .getSettingsManager().getInteger(
186                                         SettingsManager.SCOPE_GLOBAL, Keys.KEY_COUNTDOWN_DURATION);
187
188                         /** Prepare a CaptureLoggingInfo object. */
189                         final ResourceCaptureTools.CaptureLoggingInfo captureLoggingInfo
190                                 = new ResourceCaptureTools.CaptureLoggingInfo() {
191                             @Override
192                             public TouchCoordinate getTouchPointInsideShutterButton() {
193                                 return event.getTouchCoordinate();
194                             }
195
196                             @Override
197                             public int getCountDownDuration() {
198                                 return countDownDuration;
199                             }
200                         };
201
202                         /** Start counting down if the duration is not zero. */
203                         if (countDownDuration > 0) {
204                             mIsCountingDown = true;
205                             mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
206                                 @Override
207                                 public void run() {
208                                     CaptureIntentModuleUI moduleUI = mResourceCaptureTools.get().getModuleUI();
209                                     moduleUI.setCountdownFinishedListener(
210                                             new CountDownView.OnCountDownStatusListener() {
211                                                 @Override
212                                                 public void onRemainingSecondsChanged(
213                                                         int remainingSeconds) {
214                                                     mResourceCaptureTools.get()
215                                                             .playCountDownSound(remainingSeconds);
216                                                 }
217
218                                                 @Override
219                                                 public void onCountDownFinished() {
220                                                     getStateMachine().processEvent(
221                                                             new EventTimerCountDownToZero(
222                                                                     captureLoggingInfo));
223                                                 }
224                                             });
225                                     moduleUI.startCountdown(
226                                             countDownDuration);
227                                 }
228                             });
229                             return NO_CHANGE;
230                         }
231
232                         /** Otherwise, just take a picture immediately. */
233                         mIsTakingPicture = true;
234                         mResourceCaptureTools.get().takePictureNow(
235                                 mPictureCallback, captureLoggingInfo);
236                         return NO_CHANGE;
237                     }
238                 };
239         setEventHandler(EventTapOnShutterButton.class, tapOnShutterButtonHandler);
240
241         /** Handles EventTimerCountDownToZero. */
242         EventHandler<EventTimerCountDownToZero> timerCountDownToZeroHandler =
243                 new EventHandler<EventTimerCountDownToZero>() {
244                     @Override
245                     public Optional<State> processEvent(EventTimerCountDownToZero event) {
246                         if (mIsCountingDown) {
247                             mIsCountingDown = false;
248                             mIsTakingPicture = true;
249                             mResourceCaptureTools.get().takePictureNow(
250                                     mPictureCallback,
251                                     event.getCaptureLoggingInfo());
252                         }
253                         return NO_CHANGE;
254                     }
255                 };
256         setEventHandler(EventTimerCountDownToZero.class, timerCountDownToZeroHandler);
257
258         /** Handles EventTapOnSwitchCameraButton. */
259         EventHandler<EventTapOnSwitchCameraButton> tapOnSwitchCameraButtonHandler =
260                 new EventHandler<EventTapOnSwitchCameraButton>() {
261                     @Override
262                     public Optional<State> processEvent(EventTapOnSwitchCameraButton event) {
263                         final ResourceConstructed resourceConstructed =
264                                 mResourceCaptureTools.get().getResourceConstructed().get();
265
266                         // Freeze the screen.
267                         mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
268                             @Override
269                             public void run() {
270                                 resourceConstructed.getModuleUI().freezeScreenUntilPreviewReady();
271                             }
272                         });
273
274                         OneCamera.Facing cameraFacing =
275                                 resourceConstructed.getCameraFacingSetting().getCameraFacing();
276                         CameraId cameraId =  resourceConstructed.getOneCameraManager()
277                               .findFirstCameraFacing(cameraFacing);
278                         OneCameraCharacteristics characteristics;
279                         try {
280                             characteristics = resourceConstructed.getOneCameraManager()
281                                     .getOneCameraCharacteristics(cameraId);
282                         } catch (OneCameraAccessException ex) {
283                             return Optional.of((State) StateFatal.from(
284                                     StateReadyForCapture.this,
285                                     mResourceCaptureTools.get().getResourceConstructed()));
286                         }
287
288                         return Optional.of((State) StateOpeningCamera.from(
289                                 StateReadyForCapture.this,
290                                 mResourceCaptureTools.get().getResourceConstructed(),
291                                 mResourceCaptureTools.get().getResourceSurfaceTexture(),
292                                 cameraFacing,
293                                 cameraId,
294                                 characteristics));
295                     }
296                 };
297         setEventHandler(EventTapOnSwitchCameraButton.class, tapOnSwitchCameraButtonHandler);
298
299         /** Handles EventTapOnPreview. */
300         EventHandler<EventTapOnPreview> tapOnPreviewHandler = new EventHandler<EventTapOnPreview>() {
301             @Override
302             public Optional<State> processEvent(EventTapOnPreview event) {
303                 final Point tapPoint = event.getTapPoint();
304                 mResourceCaptureTools.get().getFocusController().showActiveFocusAt(
305                         tapPoint.x, tapPoint.y);
306
307                 RectF previewRect = mResourceCaptureTools.get().getModuleUI().getPreviewRect();
308                 int rotationDegree = mResourceCaptureTools.get().getResourceConstructed().get()
309                         .getOrientationManager().getDisplayRotation().getDegrees();
310
311                 // Normalize coordinates to [0,1] per CameraOne API.
312                 float points[] = new float[2];
313                 points[0] = (tapPoint.x - previewRect.left) / previewRect.width();
314                 points[1] = (tapPoint.y - previewRect.top) / previewRect.height();
315
316                 // Rotate coordinates to portrait orientation per CameraOne API.
317                 Matrix rotationMatrix = new Matrix();
318                 rotationMatrix.setRotate(rotationDegree, 0.5f, 0.5f);
319                 rotationMatrix.mapPoints(points);
320                 mResourceCaptureTools.get().getResourceOpenedCamera().get().triggerFocusAndMeterAtPoint(
321                         new PointF(points[0], points[1]));
322
323                 return NO_CHANGE;
324             }
325         };
326         setEventHandler(EventTapOnPreview.class, tapOnPreviewHandler);
327
328         /** Handles EventZoomRatioChanged. */
329         EventHandler<EventZoomRatioChanged> zoomRatioChangedHandler =
330                 new EventHandler<EventZoomRatioChanged>() {
331                     @Override
332                     public Optional<State> processEvent(EventZoomRatioChanged event) {
333                         mResourceCaptureTools.get().getResourceOpenedCamera().get().setZoomRatio(
334                                 event.getZoomRatio());
335                         return NO_CHANGE;
336                     }
337                 };
338         setEventHandler(EventZoomRatioChanged.class, zoomRatioChangedHandler);
339
340         /** Handles EventPictureCompressed. */
341         EventHandler<EventPictureCompressed> pictureCompressedHandler =
342                 new EventHandler<EventPictureCompressed>() {
343                     @Override
344                     public Optional<State> processEvent(EventPictureCompressed event) {
345                         if (mIsTakingPicture) {
346                             mIsTakingPicture = false;
347                             mIsDecodingPicture = true;
348
349                             final byte[] pictureData = event.getPictureData();
350                             final int pictureOrientation = event.getOrientation();
351                             mResourceCaptureTools.get().getResourceConstructed().get().getCameraHandler().post(
352                                     new Runnable() {
353                                         @Override
354                                         public void run() {
355                                             final Bitmap pictureBitmap = PictureDecoder.decode(
356                                                     pictureData,
357                                                     CaptureIntentConfig.DOWN_SAMPLE_FACTOR,
358                                                     pictureOrientation,
359                                                     false);
360                                             getStateMachine().processEvent(
361                                                     new EventPictureDecoded(pictureBitmap, pictureData));
362                                         }
363                                     });
364                         }
365                         return NO_CHANGE;
366                     }
367                 };
368         setEventHandler(EventPictureCompressed.class, pictureCompressedHandler);
369
370         /** Handles EventPictureDecoded. */
371         EventHandler<EventPictureDecoded> pictureDecodedHandler =
372                 new EventHandler<EventPictureDecoded>() {
373                     @Override
374                     public Optional<State> processEvent(EventPictureDecoded event) {
375                         return Optional.of((State) StateReviewingPicture.from(
376                                 StateReadyForCapture.this, mResourceCaptureTools,
377                                 event.getPictureBitmap(), Optional.of(event.getPictureData())));
378                     }
379                 };
380         setEventHandler(EventPictureDecoded.class, pictureDecodedHandler);
381
382         /** Handles EventFastPictureBitmapAvailable. */
383         EventHandler<EventFastPictureBitmapAvailable> fastPictureBitmapAvailableHandler =
384                 new EventHandler<EventFastPictureBitmapAvailable>() {
385                     @Override
386                     public Optional<State> processEvent(EventFastPictureBitmapAvailable event) {
387                         if (mIsTakingPicture && !mIsDecodingPicture) {
388                             return Optional.of((State) StateReviewingPicture.from(
389                                     StateReadyForCapture.this, mResourceCaptureTools,
390                                     event.getThumbnailBitmap(), Optional.<byte[]>absent()));
391                         }
392                         return NO_CHANGE;
393                     }
394                 };
395         setEventHandler(EventFastPictureBitmapAvailable.class, fastPictureBitmapAvailableHandler);
396
397         /** Handles EventCameraQuickExpose. */
398         EventHandler<EventCameraQuickExpose> cameraQuickExposeHandler =
399                 new EventHandler<EventCameraQuickExpose>() {
400                     @Override
401                     public Optional<State> processEvent(EventCameraQuickExpose event) {
402                         if (mIsTakingPicture) {
403                             mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
404                                 @Override
405                                 public void run() {
406                                     // Disable shutter button.
407                                     mResourceCaptureTools.get().getModuleUI().setShutterButtonEnabled(false);
408                                     // Starts the short version of the capture animation UI.
409                                     mResourceCaptureTools.get().getModuleUI().startFlashAnimation(true);
410                                     mResourceCaptureTools.get().getMediaActionSound().play(
411                                             MediaActionSound.SHUTTER_CLICK);
412                                 }
413                             });
414                         }
415                         return NO_CHANGE;
416                     }
417                 };
418         setEventHandler(EventCameraQuickExpose.class, cameraQuickExposeHandler);
419
420         /** Handles EventTapOnCancelShutterButton. */
421         EventHandler<EventTapOnCancelShutterButton> tapOnCancelShutterButtonHandler =
422                 new EventHandler<EventTapOnCancelShutterButton>() {
423                     @Override
424                     public Optional<State> processEvent(EventTapOnCancelShutterButton event) {
425                         // Cancel in this state means that the countdown was cancelled.
426                         mIsCountingDown = false;
427                         mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
428                             @Override
429                             public void run() {
430                                 mResourceCaptureTools.get().getModuleUI().cancelCountDown();
431                                 mResourceCaptureTools.get().getModuleUI().showPictureCaptureUI();
432                             }
433                         });
434                         return NO_CHANGE;
435                     }
436                 };
437         setEventHandler(EventTapOnCancelShutterButton.class, tapOnCancelShutterButtonHandler);
438     }
439
440     @Override
441     public Optional<State> onEnter() {
442         // Register various listeners. These will be unregistered in onLeave().
443         final OneCamera camera =
444                 mResourceCaptureTools.get().getResourceOpenedCamera().get().getCamera();
445         camera.setFocusDistanceListener(mResourceCaptureTools.get().getFocusController());
446         camera.setFocusStateListener(mFocusStateListener);
447         camera.setReadyStateChangedListener(mReadyStateChangedListener);
448         mResourceCaptureTools.get().getCaptureSessionManager()
449                 .addSessionListener(mCaptureSessionListener);
450
451         // Display capture UI.
452         mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
453             @Override
454             public void run() {
455                 mResourceCaptureTools.get().getModuleUI().cancelCountDown();
456                 mResourceCaptureTools.get().getModuleUI().showPictureCaptureUI();
457                 mResourceCaptureTools.get().getModuleUI().initializeZoom(
458                         mResourceCaptureTools.get().getResourceOpenedCamera().get().getZoomRatio());
459             }
460         });
461         return NO_CHANGE;
462     }
463
464     @Override
465     public void onLeave() {
466         final OneCamera camera =
467                 mResourceCaptureTools.get().getResourceOpenedCamera().get().getCamera();
468         camera.setFocusDistanceListener(null);
469         camera.setFocusStateListener(null);
470         camera.setReadyStateChangedListener(null);
471
472         mResourceCaptureTools.get().getCaptureSessionManager()
473                 .removeSessionListener(mCaptureSessionListener);
474         mResourceCaptureTools.close();
475     }
476
477     private void onFocusStateUpdated(OneCamera.AutoFocusState focusState) {
478         final FocusController focusController = mResourceCaptureTools.get().getFocusController();
479         switch (focusState) {
480             case PASSIVE_SCAN:
481                 focusController.showPassiveFocusAtCenter();
482                 break;
483             case ACTIVE_SCAN:
484                 break;
485             case PASSIVE_FOCUSED:
486             case PASSIVE_UNFOCUSED:
487                 focusController.clearFocusIndicator();
488                 break;
489             case ACTIVE_FOCUSED:
490             case ACTIVE_UNFOCUSED:
491                 focusController.clearFocusIndicator();
492                 break;
493         }
494     }
495
496     private final OneCamera.FocusStateListener mFocusStateListener =
497             new OneCamera.FocusStateListener() {
498                 @Override
499                 public void onFocusStatusUpdate(final OneCamera.AutoFocusState focusState,
500                         final long frameNumber) {
501                     onFocusStateUpdated(focusState);
502                 }
503             };
504
505     private final EventHandler<EventCameraBusy> mEventCameraBusyHandler =
506             new EventHandler<EventCameraBusy>() {
507                 @Override
508                 public Optional<State> processEvent(EventCameraBusy event) {
509                     mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
510                         @Override
511                         public void run() {
512                             mResourceCaptureTools.get().getModuleUI().setShutterButtonEnabled(
513                                     false);
514                         }
515                     });
516                     return NO_CHANGE;
517                 }
518             };
519
520     private final EventHandler<EventCameraReady> mEventCameraReadyHandler =
521             new EventHandler<EventCameraReady>() {
522                 @Override
523                 public Optional<State> processEvent(EventCameraReady event) {
524                     mResourceCaptureTools.get().getMainThread().execute(new Runnable() {
525                         @Override
526                         public void run() {
527                             mResourceCaptureTools.get().getModuleUI().setShutterButtonEnabled(true);
528                         }
529                     });
530                     return NO_CHANGE;
531                 }
532             };
533
534     private final OneCamera.ReadyStateChangedListener mReadyStateChangedListener =
535             new OneCamera.ReadyStateChangedListener() {
536                 /**
537                  * Called when the camera is either ready or not ready to take a picture
538                  * right now.
539                  */
540                 @Override
541                 public void onReadyStateChanged(final boolean readyForCapture) {
542                     if (readyForCapture) {
543                         getStateMachine().processEvent(new EventCameraReady());
544                     } else {
545                         getStateMachine().processEvent(new EventCameraBusy());
546                     }
547                 }
548             };
549
550     private final OneCamera.PictureCallback mPictureCallback = new OneCamera.PictureCallback() {
551         @Override
552         public void onQuickExpose() {
553             getStateMachine().processEvent(new EventCameraQuickExpose());
554         }
555
556         @Override
557         public void onThumbnailResult(byte[] jpegData) {
558         }
559
560         @Override
561         public void onPictureTaken(CaptureSession session) {
562         }
563
564         @Override
565         public void onPictureSaved(Uri uri) {
566         }
567
568         @Override
569         public void onPictureTakingFailed() {
570         }
571
572         @Override
573         public void onTakePictureProgress(float progress) {
574         }
575     };
576
577     private final CaptureSessionManager.SessionListener mCaptureSessionListener =
578             new CaptureSessionManager.SessionListener() {
579                 @Override
580                 public void onSessionThumbnailUpdate(Bitmap thumbnailBitmap) {
581                     getStateMachine().processEvent(
582                             new EventFastPictureBitmapAvailable(thumbnailBitmap));
583                 }
584
585                 @Override
586                 public void onSessionPictureDataUpdate(byte[] pictureData, int orientation) {
587                     getStateMachine().processEvent(
588                             new EventPictureCompressed(pictureData, orientation));
589                 }
590
591                 @Override
592                 public void onSessionQueued(Uri sessionUri) {
593                 }
594
595                 @Override
596                 public void onSessionUpdated(Uri sessionUri) {
597                 }
598
599                 @Override
600                 public void onSessionCaptureIndicatorUpdate(Bitmap bitmap, int rotationDegrees) {
601                 }
602
603                 @Override
604                 public void onSessionDone(Uri sessionUri) {
605                 }
606
607                 @Override
608                 public void onSessionFailed(Uri sessionUri, int failureMessageId,
609                         boolean removeFromFilmstrip) {
610                 }
611
612                 @Override
613                 public void onSessionCanceled(Uri mediaUri) {
614                 }
615
616                 @Override
617                 public void onSessionProgress(Uri sessionUri, int progress) {
618                 }
619
620                 @Override
621                 public void onSessionProgressText(Uri sessionUri, int messageId) {
622                 }
623             };
624 }