OSDN Git Service

N4 CaptureModule not closing
authorI-Jong Lin <ijonglin@google.com>
Wed, 11 Feb 2015 23:01:05 +0000 (15:01 -0800)
committerI-Jong Lin <ijonglin@google.com>
Wed, 11 Feb 2015 23:29:51 +0000 (15:29 -0800)
N4 CaptureModule was not wired up properly to close the device when it
closed.  There's still an issue that the synchronization is incorrect,
i.e. we don't guarentee close has completed before we open it again.
There's a fix so that we can use OnCameraAvailable listener to only open
the camera when it is available.

Bug: 19332637
Change-Id: Ie88acb3a9f75a5896606dd660c005de0dc82dc3c

src/com/android/camera/async/ListenableConcurrentState.java
src/com/android/camera/module/ModulesInfo.java
src/com/android/camera/one/v2/SimpleOneCameraFactory.java
src/com/android/camera/one/v2/initialization/GenericOneCameraImpl.java

index aa691d2..ec647a1 100644 (file)
@@ -59,6 +59,7 @@ public class ListenableConcurrentState<T> implements Listenable<T> {
                 }
             }, mExecutor);
         }
+        callback.onCallback(mState.get());
     }
 
     @Override
index e024806..327df75 100644 (file)
@@ -38,7 +38,6 @@ public class ModulesInfo {
     private static final Log.Tag TAG = new Log.Tag("ModulesInfo");
 
     /** Selects CaptureModule if true, PhotoModule if false. */
-    // TODO: DO __NOT__ TURN ON BY DEFAULT FOR NEXUS4
     private static final boolean ENABLE_CAPTURE_MODULE = ApiHelper.HAS_CAMERA_2_API
             && (ApiHelper.IS_NEXUS_5 || ApiHelper.IS_NEXUS_6 || ApiHelper.IS_NEXUS_9);
 
index 9cf6192..09f3a87 100644 (file)
@@ -101,6 +101,7 @@ public class SimpleOneCameraFactory implements OneCameraFactory {
                 Loggers.tagFactory()));
 
         lifetime.add(imageReader);
+        lifetime.add(device);
 
         List<Surface> outputSurfaces = new ArrayList<>();
         outputSurfaces.add(imageReader.getSurface());
index 32c2cb1..519fba0 100644 (file)
@@ -112,8 +112,10 @@ class GenericOneCameraImpl implements OneCamera {
                 // TODO delete frameNumber from FocusStateListener callback. It
                 // is optional and never actually used.
                 long frameNumber = -1;
-                listener.onFocusStatusUpdate(AutoFocusHelper.stateFromCamera2State(afState),
-                        frameNumber);
+                if(listener !=null) {
+                    listener.onFocusStatusUpdate(AutoFocusHelper.stateFromCamera2State(afState),
+                            frameNumber);
+                }
             }
         });
     }