Merge "Native 16x9 viewfinder stream for Gcam to reduce switching jank and eliminate black bar overlay hack." into ub-camera-glacier
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 01c9dda..8d0c759 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -58,10 +58,6 @@
android:theme="@style/Theme.Camera"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" >
<intent-filter>
- <action android:name="android.media.action.IMAGE_CAPTURE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
<action android:name="android.media.action.STILL_IMAGE_CAMERA" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
@@ -87,11 +83,23 @@
</intent-filter>
</activity-alias>
+ <activity
+ android:name="com.android.camera.CaptureActivity"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.Camera"
+ android:configChanges="orientation|screenSize|keyboardHidden"
+ android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
+ <intent-filter>
+ <action android:name="android.media.action.IMAGE_CAPTURE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<!-- Video camera and capture use the Camcorder label and icon. -->
<activity-alias
android:name="com.android.camera.VideoCamera"
android:label="@string/video_camera_label"
- android:targetActivity="com.android.camera.CameraActivity">
+ android:targetActivity="com.android.camera.CaptureActivity">
<intent-filter>
<action android:name="android.media.action.VIDEO_CAMERA" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 3d29d5a..0e5a9e5 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -102,7 +102,7 @@
<color name="focus_outer_ring_color">#4CFFFFFF</color>
<color name="fullscreen_dialog_background_color">@color/main_color_global</color>
<color name="dialog_button_color">#FF76A7F9</color>
- <color name="dialog_text_color">#DF000000</color>
+ <color name="dialog_text_color">@android:color/white</color>
<color name="settings_cling_color">#2962FF</color>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 2e72f55..12edaf5 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -129,7 +129,7 @@
import com.android.camera.util.IntentHelper;
import com.android.camera.util.PhotoSphereHelper.PanoramaViewHelper;
import com.android.camera.util.QuickActivity;
-import com.android.camera.util.ReleaseDialogHelper;
+import com.android.camera.util.ReleaseHelper;
import com.android.camera.util.UsageStatistics;
import com.android.camera.widget.FilmstripView;
import com.android.camera.widget.Preloader;
@@ -389,8 +389,8 @@
fileAgeFromDataID(currentDataId));
// If applicable, show release information before this item
// is shared.
- if (ReleaseDialogHelper.shouldShowReleaseInfoDialogOnShare(data)) {
- ReleaseDialogHelper.showReleaseInfoDialog(CameraActivity.this,
+ if (ReleaseHelper.shouldShowReleaseInfoDialogOnShare(data)) {
+ ReleaseHelper.showReleaseInfoDialog(CameraActivity.this,
new Callback<Void>() {
@Override
public void onCallback(Void result) {
@@ -1320,16 +1320,20 @@
private final CameraExceptionHandler.CameraExceptionCallback mCameraExceptionCallback
= new CameraExceptionHandler.CameraExceptionCallback() {
@Override
+ public void onCameraError(int errorCode) {
+ Log.e(TAG, "Camera error callback. error=" + errorCode);
+ }
+ @Override
public void onCameraException(RuntimeException ex) {
Log.e(TAG, "Camera Exception", ex);
- onFatalError(ex);
+ onFatalError();
}
@Override
public void onDispatchThreadException(RuntimeException ex) {
Log.e(TAG, "DispatchThread Exception", ex);
- onFatalError(ex);
+ onFatalError();
}
- private void onFatalError(RuntimeException ex) {
+ private void onFatalError() {
mCameraFatalError = true;
// If the activity receives exception during onPause, just exit the app.
if (mPaused && !isFinishing()) {
@@ -1828,7 +1832,7 @@
});
mPanoramaViewHelper.onResume();
- ReleaseDialogHelper.showReleaseInfoDialogOnStart(this, mSettingsManager);
+ ReleaseHelper.showReleaseInfoDialogOnStart(this, mSettingsManager);
syncLocationManagerSetting();
final int previewVisibility = getPreviewVisibility();
diff --git a/src/com/android/camera/CameraErrorCallback.java b/src/com/android/camera/CameraErrorCallback.java
deleted file mode 100644
index 5f69332..0000000
--- a/src/com/android/camera/CameraErrorCallback.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import com.android.camera.debug.Log;
-import com.android.ex.camera2.portability.CameraAgent;
-
-public class CameraErrorCallback
- implements CameraAgent.CameraErrorCallback {
- private static final Log.Tag TAG = new Log.Tag("CamErrCallback");
-
- @Override
- public void onError(int error, CameraAgent.CameraProxy camera) {
- Log.e(TAG, "Got camera error callback. error=" + error);
- if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
- // We are not sure about the current state of the app (in preview or
- // snapshot or recording). Closing the app is better than creating a
- // new Camera object.
- throw new RuntimeException("Media server died.");
- }
- }
-}
diff --git a/src/com/android/camera/CaptureActivity.java b/src/com/android/camera/CaptureActivity.java
new file mode 100644
index 0000000..6b9b915
--- /dev/null
+++ b/src/com/android/camera/CaptureActivity.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera;
+
+// Use a different activity for capture intents, so it can have a different
+// task affinity from others. This makes sure the regular camera activity is not
+// reused for IMAGE_CAPTURE or VIDEO_CAPTURE intents from other activities.
+public class CaptureActivity extends CameraActivity {
+}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index d4da14b..8c1c88c 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -29,9 +29,7 @@
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.location.Location;
-import android.media.AudioManager;
import android.media.CameraProfile;
-import android.media.SoundPool;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
@@ -222,8 +220,6 @@
? new AutoFocusMoveCallback()
: null;
- private final CameraErrorCallback mErrorCallback = new CameraErrorCallback();
-
private long mFocusStartTime;
private long mShutterCallbackTime;
private long mPostViewPictureCallbackTime;
@@ -1062,7 +1058,7 @@
mJpegPictureCallbackTime = 0;
final ExifInterface exif = Exif.getExif(originalJpegData);
-
+ final NamedEntity name = mNamedImages.getNextNameEntity();
if (mShouldResizeTo16x9) {
final ResizeBundle dataBundle = new ResizeBundle();
dataBundle.jpegData = originalJpegData;
@@ -1077,17 +1073,17 @@
@Override
protected void onPostExecute(ResizeBundle result) {
- saveFinalPhoto(result.jpegData, result.exif, camera);
+ saveFinalPhoto(result.jpegData, name, result.exif, camera);
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, dataBundle);
} else {
- saveFinalPhoto(originalJpegData, exif, camera);
+ saveFinalPhoto(originalJpegData, name, exif, camera);
}
}
- void saveFinalPhoto(final byte[] jpegData, final ExifInterface exif, CameraProxy camera) {
-
+ void saveFinalPhoto(final byte[] jpegData, NamedEntity name, final ExifInterface exif,
+ CameraProxy camera) {
int orientation = Exif.getOrientation(exif);
float zoomValue = 1.0f;
@@ -1101,7 +1097,7 @@
boolean gridLinesOn = Keys.areGridLinesOn(mActivity.getSettingsManager());
UsageStatistics.instance().photoCaptureDoneEvent(
eventprotos.NavigationChange.Mode.PHOTO_CAPTURE,
- mNamedImages.mQueue.lastElement().title + ".jpg", exif,
+ name.title + ".jpg", exif,
isCameraFrontFacing(), hdrOn, zoomValue, flashSetting, gridLinesOn,
(float) mTimerDuration, mShutterTouchCoordinate, mVolumeButtonClickedFlag);
mShutterTouchCoordinate = null;
@@ -1126,7 +1122,6 @@
height = s.width();
}
}
- NamedEntity name = mNamedImages.getNextNameEntity();
String title = (name == null) ? null : name.title;
long date = (name == null) ? -1 : name.date;
@@ -1858,7 +1853,6 @@
stopFaceDetection();
mCameraDevice.setZoomChangeListener(null);
mCameraDevice.setFaceDetectionCallback(null, null);
- mCameraDevice.setErrorCallback(null, null);
mFaceDetectionStarted = false;
mActivity.getCameraProvider().releaseCamera(mCameraDevice.getCameraId());
@@ -1931,7 +1925,6 @@
return;
}
- mCameraDevice.setErrorCallback(mHandler, mErrorCallback);
setDisplayOrientation();
if (!mSnapshotOnIdle) {
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 39fc13b..ce53dc2 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -129,8 +129,6 @@
private boolean mIsInReviewMode;
private boolean mSnapshotInProgress = false;
- private final CameraErrorCallback mErrorCallback = new CameraErrorCallback();
-
// Preference must be read before starting preview. We check this before starting
// preview.
private boolean mPreferenceRead;
@@ -898,7 +896,6 @@
return;
}
- mCameraDevice.setErrorCallback(mHandler, mErrorCallback);
if (mPreviewing == true) {
stopPreview();
}
@@ -982,7 +979,6 @@
return;
}
mCameraDevice.setZoomChangeListener(null);
- mCameraDevice.setErrorCallback(null, null);
mActivity.getCameraProvider().releaseCamera(mCameraDevice.getCameraId());
mCameraDevice = null;
mPreviewing = false;
diff --git a/src/com/android/camera/app/CameraController.java b/src/com/android/camera/app/CameraController.java
index 26cc394..c6f5d62 100644
--- a/src/com/android/camera/app/CameraController.java
+++ b/src/com/android/camera/app/CameraController.java
@@ -160,13 +160,6 @@
public void onCameraOpened(CameraAgent.CameraProxy camera) {
Log.v(TAG, "onCameraOpened");
if (mRequestingCameraId != camera.getCameraId()) {
- // Not requesting any camera or not waiting for this one, so close
- // it.
- if (mUsingNewApi) {
- mCameraAgentNg.closeCamera(camera, false);
- } else {
- mCameraAgent.closeCamera(camera, false);
- }
return;
}
mCameraProxy = camera;
@@ -288,10 +281,6 @@
* TODO: Make this method package private.
*/
public void closeCamera(boolean synced) {
- if (mCameraProxy == null) {
- Log.v(TAG, "No camera open, not closing");
- return;
- }
Log.v(TAG, "Closing camera");
mCameraProxy = null;
if (mUsingNewApi) {
diff --git a/src/com/android/camera/debug/DebugCameraProxy.java b/src/com/android/camera/debug/DebugCameraProxy.java
index b847d87..05e8229 100644
--- a/src/com/android/camera/debug/DebugCameraProxy.java
+++ b/src/com/android/camera/debug/DebugCameraProxy.java
@@ -216,12 +216,6 @@
}
@Override
- public void setErrorCallback(Handler handler, CameraAgent.CameraErrorCallback cb) {
- log("setErrorCallback");
- mProxy.setErrorCallback(handler, cb);
- }
-
- @Override
public void setParameters(Camera.Parameters params) {
log("setParameters");
mProxy.setParameters(params);
diff --git a/src/com/android/camera/debug/Log.java b/src/com/android/camera/debug/Log.java
index b6a8e8c..1b3c98c 100644
--- a/src/com/android/camera/debug/Log.java
+++ b/src/com/android/camera/debug/Log.java
@@ -16,6 +16,10 @@
package com.android.camera.debug;
+import android.os.Build;
+
+import com.android.camera.util.ReleaseHelper;
+
public class Log {
/**
* All Camera logging using this class will use this tag prefix.
@@ -123,13 +127,22 @@
// than the desired output level. This applies to all tags.
return LogHelper.getOverrideLevel() <= level;
} else {
- // The prefix can be used as an override tag to see all camera logs
- return android.util.Log.isLoggable(CAMERA_LOGTAG_PREFIX, level)
- || android.util.Log.isLoggable(tag.toString(), level);
+ return ReleaseHelper.shouldLogVerbose() ||
+ isDebugOsBuild() || shouldLog(tag, level);
}
} catch (IllegalArgumentException ex) {
e(TAG, "Tag too long:" + tag);
return false;
}
}
+
+ private static boolean shouldLog(Tag tag, int level) {
+ // The prefix can be used as an override tag to see all camera logs
+ return android.util.Log.isLoggable(CAMERA_LOGTAG_PREFIX, level)
+ || android.util.Log.isLoggable(tag.toString(), level);
+ }
+
+ private static boolean isDebugOsBuild() {
+ return "userdebug".equals(Build.TYPE) || "eng".equals(Build.TYPE);
+ }
}
diff --git a/src_pd/com/android/camera/util/ReleaseDialogHelper.java b/src_pd/com/android/camera/util/ReleaseHelper.java
similarity index 91%
rename from src_pd/com/android/camera/util/ReleaseDialogHelper.java
rename to src_pd/com/android/camera/util/ReleaseHelper.java
index 9db1245..dd41125 100644
--- a/src_pd/com/android/camera/util/ReleaseDialogHelper.java
+++ b/src_pd/com/android/camera/util/ReleaseHelper.java
@@ -21,7 +21,7 @@
import com.android.camera.data.LocalData;
import com.android.camera.settings.SettingsManager;
-public class ReleaseDialogHelper {
+public class ReleaseHelper {
public static void showReleaseInfoDialogOnStart(Activity activity,
SettingsManager settingsManager) {
// Do nothing.
@@ -34,4 +34,8 @@
public static boolean shouldShowReleaseInfoDialogOnShare(LocalData data) {
return false;
}
+
+ public static boolean shouldLogVerbose() {
+ return false;
+ }
}