OSDN Git Service

Merge "Workaround for future GPS timestamps" into ub-camera-haleakala
authorAlan Newberger <alann@google.com>
Tue, 10 Mar 2015 21:07:00 +0000 (21:07 +0000)
committerAndroid (Google) Code Review <android-gerrit@google.com>
Tue, 10 Mar 2015 21:07:02 +0000 (21:07 +0000)
src/com/android/camera/VideoModule.java
src/com/android/camera/app/CameraAppUI.java
src/com/android/camera/captureintent/CaptureIntentModule.java
src/com/android/camera/captureintent/CaptureIntentModuleUI.java
src/com/android/camera/captureintent/state/StateOpeningCamera.java
src/com/android/camera/one/v2/OneCameraManagerImpl.java

index d00af6d..742ce25 100644 (file)
@@ -602,6 +602,7 @@ public class VideoModule extends CameraModule
 
     private void startPlayVideoActivity() {
         Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         intent.setDataAndType(mCurrentVideoUri, convertOutputFormatToMimeType(mProfile.fileFormat));
         try {
             mActivity.launchActivityByIntent(intent);
index cd334d7..a9021aa 100644 (file)
@@ -1214,7 +1214,13 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
     public void onChangeCamera() {
         ModuleController moduleController = mController.getCurrentModuleController();
         applyModuleSpecs(moduleController.getHardwareSpec(), moduleController.getBottomBarSpec());
+        syncModeOptionIndicators();
+    }
 
+    /**
+     * Updates the mode option indicators according to the current settings.
+     */
+    public void syncModeOptionIndicators() {
         if (mIndicatorIconController != null) {
             // Sync the settings state with the indicator state.
             mIndicatorIconController.syncIndicators();
index dde0030..c439578 100644 (file)
@@ -24,10 +24,8 @@ import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
 
-import com.android.camera.ButtonManager;
 import com.android.camera.CameraActivity;
 import com.android.camera.CameraModule;
-import com.android.camera.FatalErrorHandler;
 import com.android.camera.app.AppController;
 import com.android.camera.app.CameraAppUI;
 import com.android.camera.async.MainThread;
@@ -42,18 +40,12 @@ import com.android.camera.captureintent.stateful.StateMachine;
 import com.android.camera.captureintent.stateful.StateMachineImpl;
 import com.android.camera.debug.Log;
 import com.android.camera.hardware.HardwareSpec;
-import com.android.camera.one.OneCamera;
-import com.android.camera.one.OneCameraAccessException;
-import com.android.camera.one.OneCameraCharacteristics;
-import com.android.camera.settings.CameraFacingSetting;
 import com.android.camera.settings.SettingsManager;
-import com.android.camera.stats.UsageStatistics;
 import com.android.camera.ui.PreviewStatusListener;
 import com.android.camera.ui.TouchCoordinate;
 import com.android.camera.util.Size;
 import com.android.camera2.R;
 import com.android.ex.camera2.portability.CameraAgent;
-import com.google.common.logging.eventprotos;
 
 /**
  * The camera module that handles image capture intent.
@@ -143,7 +135,6 @@ public class CaptureIntentModule extends CameraModule {
     public void resume() {
         mModuleUI.onModuleResumed();
         mResourceConstructed.get().getAppController().addPreviewAreaSizeChangedListener(mModuleUI);
-        mResourceConstructed.get().getAppController().getCameraAppUI().onChangeCamera();
         mStateMachine.processEvent(new EventResume());
     }
 
@@ -177,88 +168,22 @@ public class CaptureIntentModule extends CameraModule {
 
     @Override
     public HardwareSpec getHardwareSpec() {
-        final CameraFacingSetting cameraFacingSetting =
-                mResourceConstructed.get().getCameraFacingSetting();
-        final OneCameraCharacteristics characteristics;
-        try {
-            characteristics = mResourceConstructed.get().getCameraManager()
-                    .getCameraCharacteristics(cameraFacingSetting.getCameraFacing());
-        } catch (OneCameraAccessException ocae) {
-            mResourceConstructed.get().getFatalErrorHandler().onGenericCameraAccessFailure();
-            return null;
-        }
-
-        return new HardwareSpec() {
-            @Override
-            public boolean isFrontCameraSupported() {
-                return mResourceConstructed.get().getCameraManager()
-                        .hasCameraFacing(OneCamera.Facing.FRONT);
-            }
-
-            @Override
-            public boolean isHdrSupported() {
-                return false;
-            }
-
-            @Override
-            public boolean isHdrPlusSupported() {
-                return false;
-            }
-
-            @Override
-            public boolean isFlashSupported() {
-                return characteristics.isFlashSupported();
-            }
-        };
+        /**
+         * Instead of passively providing CameraAppUI the hardware spec here,
+         * {@link com.android.camera.captureintent.state.StateOpeningCamera}
+         * will actively specify hardware spec.
+         */
+        return null;
     }
 
     @Override
     public CameraAppUI.BottomBarUISpec getBottomBarSpec() {
-        CameraAppUI.BottomBarUISpec bottomBarSpec = new CameraAppUI.BottomBarUISpec();
-        /** Camera switch button UI spec. */
-        bottomBarSpec.enableCamera = true;
-        bottomBarSpec.cameraCallback = new ButtonManager.ButtonCallback() {
-            @Override
-            public void onStateChanged(int cameraId) {
-                mStateMachine.processEvent(new EventTapOnSwitchCameraButton());
-            }
-        };
-        /** Grid lines button UI spec. */
-        bottomBarSpec.enableGridLines = true;
-        /** HDR button UI spec. */
-        bottomBarSpec.enableHdr = false;
-        bottomBarSpec.hideHdr = true;
-        bottomBarSpec.hdrCallback = null;
-        /** Timer button UI spec. */
-        bottomBarSpec.enableSelfTimer = true;
-        bottomBarSpec.showSelfTimer = true;
-        /** Flash button UI spec. */
-        bottomBarSpec.enableFlash = true;
-        bottomBarSpec.hideFlash = false;
-
-        /** Intent image review UI spec. */
-        bottomBarSpec.showCancel = true;
-        bottomBarSpec.cancelCallback = new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                mStateMachine.processEvent(new EventTapOnCancelIntentButton());
-            }
-        };
-        bottomBarSpec.showDone = true;
-        bottomBarSpec.doneCallback = new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                mStateMachine.processEvent(new EventTapOnConfirmPhotoButton());
-            }
-        };
-        bottomBarSpec.showRetake = true;
-        bottomBarSpec.retakeCallback = new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                mStateMachine.processEvent(new EventTapOnRetakePhotoButton());
-            }
-        };
-        return bottomBarSpec;
+        /**
+         * Instead of passively providing CameraAppUI the bottom bar spec here,
+         * {@link com.android.camera.captureintent.state.StateOpeningCamera}
+         * will actively specify bottom bar spec.
+         */
+        return null;
     }
 
     @Override
index 6a3963c..c73e09c 100644 (file)
@@ -18,6 +18,7 @@ package com.android.camera.captureintent;
 
 import com.android.camera.app.CameraAppUI;
 import com.android.camera.async.MainThread;
+import com.android.camera.hardware.HardwareSpec;
 import com.android.camera.ui.CountDownView;
 import com.android.camera.ui.PreviewOverlay;
 import com.android.camera.ui.PreviewStatusListener;
@@ -101,6 +102,19 @@ public class CaptureIntentModuleUI implements PreviewStatusListener.PreviewAreaC
     }
 
     /**
+     * Configures the bottom bar UI.
+     *
+     * @param hardwareSpec The hardware spec.
+     * @param bottomBarSpec The bottom bar spec.
+     */
+    public void applyModuleSpecs(
+            HardwareSpec hardwareSpec,
+            CameraAppUI.BottomBarUISpec bottomBarSpec) {
+        MainThread.checkMainThread();
+        mAppUI.applyModuleSpecs(hardwareSpec, bottomBarSpec);
+    }
+
+    /**
      * Called when the module got resumed.
      */
     public void onModuleResumed() {
@@ -228,8 +242,9 @@ public class CaptureIntentModuleUI implements PreviewStatusListener.PreviewAreaC
         mIntentReviewImageView.setImageBitmap(null);
 
         mAppUI.transitionToIntentCaptureLayout();
-        mAppUI.showModeOptions();
+        mAppUI.syncModeOptionIndicators();
         mAppUI.enableModeOptions();
+        mAppUI.showModeOptions();
         mAppUI.setShutterButtonEnabled(true);
         mAppUI.setShouldSuppressCaptureIndicator(true);
     }
index bdec5c5..28dc44e 100644 (file)
@@ -19,7 +19,13 @@ package com.android.camera.captureintent.state;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 
+import com.android.camera.ButtonManager;
+import com.android.camera.app.CameraAppUI;
 import com.android.camera.async.RefCountBase;
+import com.android.camera.captureintent.event.EventTapOnCancelIntentButton;
+import com.android.camera.captureintent.event.EventTapOnConfirmPhotoButton;
+import com.android.camera.captureintent.event.EventTapOnRetakePhotoButton;
+import com.android.camera.captureintent.event.EventTapOnSwitchCameraButton;
 import com.android.camera.captureintent.resource.ResourceConstructed;
 import com.android.camera.captureintent.resource.ResourceSurfaceTexture;
 import com.android.camera.captureintent.stateful.EventHandler;
@@ -29,6 +35,7 @@ import com.android.camera.captureintent.event.EventPause;
 import com.android.camera.captureintent.stateful.State;
 import com.android.camera.captureintent.stateful.StateImpl;
 import com.android.camera.debug.Log;
+import com.android.camera.hardware.HardwareSpec;
 import com.android.camera.one.OneCamera;
 import com.android.camera.one.OneCameraAccessException;
 import com.android.camera.one.OneCameraCaptureSetting;
@@ -37,6 +44,8 @@ import com.android.camera.one.v2.photo.ImageRotationCalculator;
 import com.android.camera.one.v2.photo.ImageRotationCalculatorImpl;
 import com.android.camera.util.Size;
 
+import android.view.View;
+
 /**
  * Represents a state that the module is waiting for a camera to be opened.
  */
@@ -122,6 +131,15 @@ public final class StateOpeningCamera extends StateImpl {
                                     mResourceConstructed,
                                     mResourceSurfaceTexture));
                         }
+
+                        mResourceConstructed.get().getMainThread().execute(new Runnable() {
+                            @Override
+                            public void run() {
+                                mResourceConstructed.get().getModuleUI().applyModuleSpecs(
+                                        getHardwareSpec(), getBottomBarSpec());
+                            }
+                        });
+
                         return Optional.of((State) StateStartingPreview.from(
                                 StateOpeningCamera.this,
                                 mResourceConstructed,
@@ -193,4 +211,76 @@ public final class StateOpeningCamera extends StateImpl {
     public boolean isPaused() {
         return mIsPaused;
     }
+
+    private HardwareSpec getHardwareSpec() {
+        return new HardwareSpec() {
+            @Override
+            public boolean isFrontCameraSupported() {
+                return mResourceConstructed.get().getCameraManager()
+                        .hasCameraFacing(OneCamera.Facing.FRONT);
+            }
+
+            @Override
+            public boolean isHdrSupported() {
+                return false;
+            }
+
+            @Override
+            public boolean isHdrPlusSupported() {
+                return false;
+            }
+
+            @Override
+            public boolean isFlashSupported() {
+                return mCameraCharacteristics.isFlashSupported();
+            }
+        };
+    }
+
+    private CameraAppUI.BottomBarUISpec getBottomBarSpec() {
+        CameraAppUI.BottomBarUISpec bottomBarSpec = new CameraAppUI.BottomBarUISpec();
+        /** Camera switch button UI spec. */
+        bottomBarSpec.enableCamera = true;
+        bottomBarSpec.cameraCallback = new ButtonManager.ButtonCallback() {
+            @Override
+            public void onStateChanged(int cameraId) {
+                getStateMachine().processEvent(new EventTapOnSwitchCameraButton());
+            }
+        };
+        /** Grid lines button UI spec. */
+        bottomBarSpec.enableGridLines = true;
+        /** HDR button UI spec. */
+        bottomBarSpec.enableHdr = false;
+        bottomBarSpec.hideHdr = true;
+        bottomBarSpec.hdrCallback = null;
+        /** Timer button UI spec. */
+        bottomBarSpec.enableSelfTimer = true;
+        bottomBarSpec.showSelfTimer = true;
+        /** Flash button UI spec. */
+        bottomBarSpec.enableFlash = mCameraCharacteristics.isFlashSupported();
+
+        /** Intent image review UI spec. */
+        bottomBarSpec.showCancel = true;
+        bottomBarSpec.cancelCallback = new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                getStateMachine().processEvent(new EventTapOnCancelIntentButton());
+            }
+        };
+        bottomBarSpec.showDone = true;
+        bottomBarSpec.doneCallback = new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                getStateMachine().processEvent(new EventTapOnConfirmPhotoButton());
+            }
+        };
+        bottomBarSpec.showRetake = true;
+        bottomBarSpec.retakeCallback = new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                getStateMachine().processEvent(new EventTapOnRetakePhotoButton());
+            }
+        };
+        return bottomBarSpec;
+    }
 }
index 02ab8bc..7563104 100644 (file)
@@ -138,6 +138,10 @@ public class OneCameraManagerImpl extends OneCameraManager {
                         isFirstCallback = false;
                         device.close();
                         openCallback.onFailure();
+                    } else {
+                        // Ensures we handle the case where an error occurs
+                        // after the camera has been opened.
+                        fatalErrorHandler.onGenericCameraAccessFailure();
                     }
                 }