summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/one
diff options
context:
space:
mode:
authorSam Hasinoff <hasinoff@google.com>2014-08-26 22:12:00 -0700
committerSam Hasinoff <hasinoff@google.com>2014-08-27 22:34:28 +0000
commit4f0d63848684cb7cbcde42b0bd714bb6d6f998f5 (patch)
treead06c5fbaa3a1c43dd858d08f20ecc46766a3a57 /src/com/android/camera/one
parent2b3cf8689d68444dcf8f56a85d8525533d9d96aa (diff)
downloadandroid_packages_apps_Camera2-4f0d63848684cb7cbcde42b0bd714bb6d6f998f5.tar.gz
android_packages_apps_Camera2-4f0d63848684cb7cbcde42b0bd714bb6d6f998f5.tar.bz2
android_packages_apps_Camera2-4f0d63848684cb7cbcde42b0bd714bb6d6f998f5.zip
gcam: Restore naming of Gcam debug folders.
When Gcam debugging is on, write output to per-burst folders named SSSS_YYYYMMDD_HHMMSS_XXX, where 'SSSS' is the last 4 digits of the device serial number and 'XXX' are the milliseconds of the timestamp. Bug: 17204023 Change-Id: Ie1d58dc3ecb5d9dc7389d24acc4937498f00dbc9
Diffstat (limited to 'src/com/android/camera/one')
-rw-r--r--src/com/android/camera/one/AbstractOneCamera.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/com/android/camera/one/AbstractOneCamera.java b/src/com/android/camera/one/AbstractOneCamera.java
index 25848b60b..9b473a77f 100644
--- a/src/com/android/camera/one/AbstractOneCamera.java
+++ b/src/com/android/camera/one/AbstractOneCamera.java
@@ -17,6 +17,9 @@
package com.android.camera.one;
import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
/**
* A common abstract {@link OneCamera} implementation that contains some utility
@@ -29,6 +32,12 @@ public abstract class AbstractOneCamera implements OneCamera {
protected FocusStateListener mFocusStateListener;
protected ReadyStateChangedListener mReadyStateChangedListener;
+ /**
+ * Number of characters from the end of the device serial number used to
+ * construct folder names for debugging output.
+ */
+ static final int DEBUG_FOLDER_SERIAL_LENGTH = 4;
+
@Override
public final void setCameraErrorListener(CameraErrorListener listener) {
mCameraErrorListener = listener;
@@ -47,6 +56,10 @@ public abstract class AbstractOneCamera implements OneCamera {
/**
* Create a directory we can use to store debugging information during Gcam
* captures.
+ * <br />
+ * The directory created is [root]/[folderName]/SSSS_YYYYMMDD_HHMMSS_XXX,
+ * where 'SSSS' are the last 'DEBUG_FOLDER_SERIAL_LENGTH' digits of the
+ * devices serial number, and 'XXX' are milliseconds of the timestamp.
*
* @param root the root into which we put a session-specific sub-directory.
* @param folderName the sub-folder within 'root' where the data should be
@@ -62,8 +75,25 @@ public abstract class AbstractOneCamera implements OneCamera {
throw new RuntimeException("Gcam debug directory not valid or doesn't exist: "
+ root.getAbsolutePath());
}
- File destFolder = (new File(new File(root, folderName),
- String.valueOf(System.currentTimeMillis())));
+
+ String serialSubstring = "";
+ String serial = android.os.Build.SERIAL;
+ if (serial != null) {
+ int length = serial.length();
+
+ if (length > DEBUG_FOLDER_SERIAL_LENGTH) {
+ serialSubstring = serial.substring(length - DEBUG_FOLDER_SERIAL_LENGTH, length);
+ } else {
+ serialSubstring = serial;
+ }
+ }
+
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS");
+ simpleDateFormat.setTimeZone(TimeZone.getDefault());
+ String currentDateAndTime = simpleDateFormat.format(new Date());
+
+ String burstFolderName = String.format("%s_%s", serialSubstring, currentDateAndTime);
+ File destFolder = new File(new File(root, folderName), burstFolderName);
if (!destFolder.mkdirs()) {
throw new RuntimeException("Could not create Gcam debug data folder.");
}