summaryrefslogtreecommitdiffstats
path: root/camera2
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2014-03-11 16:27:30 -0700
committerEd Heyl <edheyl@google.com>2014-06-18 10:24:44 -0700
commitb35ea0d2d494ba7668b0183dfc906cde0708bc55 (patch)
tree467992177ce8cce6a4876180b9313b89cf7ada7a /camera2
parent653cc72d040f693e30aa0666b0190ffd226a060c (diff)
downloadandroid_frameworks_ex-b35ea0d2d494ba7668b0183dfc906cde0708bc55.tar.gz
android_frameworks_ex-b35ea0d2d494ba7668b0183dfc906cde0708bc55.tar.bz2
android_frameworks_ex-b35ea0d2d494ba7668b0183dfc906cde0708bc55.zip
Use debug.Log instead of android.util.Log.
see http://ag/438423, merge conflicts solved. 1. Change to use com.android.camera.debug.Log instead of android.util.Log. 2. Add DebugCameraProxy to support more detailed debug info. 3. Add CameraErrorCallback in CameraManager. 4. Support posting to a specific handler for CameraErrorCallback. 5. Trim down some TAGs to match the framework tag length limit. 6. Remove some unused codes in CameraSettings. bug:13324870 Change-Id: I8c20a8a0d11cfd50b6e199b03cbc88d3c4ad2ceb Conflicts: src/com/android/camera/data/LocalMediaData.java src/com/android/camera/data/RotationTask.java src/com/android/camera/widget/FilmstripView.java
Diffstat (limited to 'camera2')
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/debug/Log.java205
1 files changed, 205 insertions, 0 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/debug/Log.java b/camera2/portability/src/com/android/ex/camera2/portability/debug/Log.java
new file mode 100644
index 0000000..a9e6d91
--- /dev/null
+++ b/camera2/portability/src/com/android/ex/camera2/portability/debug/Log.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2014 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.ex.camera2.portability.debug;
+
+public class Log {
+ public static final String CAMERA_LOGTAG_PREFIX = "CAM2PORT_";
+ private static final Log.Tag TAG = new Log.Tag("Log");
+
+ /**
+ * This class restricts the length of the log tag to be less than the
+ * framework limit and also prepends the common tag prefix defined by
+ * {@code CAMERA_LOGTAG_PREFIX}.
+ */
+ public static final class Tag {
+
+ // The length limit from Android framework is 23.
+ private static final int MAX_TAG_LEN = 23 - CAMERA_LOGTAG_PREFIX.length();
+
+ final String mValue;
+
+ public Tag(String tag) {
+ final int lenDiff = tag.length() - MAX_TAG_LEN;
+ if (lenDiff > 0) {
+ w(TAG, "Tag " + tag + " is " + lenDiff + " chars longer than limit.");
+ }
+ mValue = CAMERA_LOGTAG_PREFIX + (lenDiff > 0 ? tag.substring(0, MAX_TAG_LEN) : tag);
+ }
+
+ @Override
+ public String toString() {
+ return mValue;
+ }
+ }
+
+ private interface Logger {
+ void log(Tag tag, String msg);
+ void log(Tag tag, String msg, Throwable tr);
+ }
+
+ private static final Logger SILENT_LOGGER = new Logger() {
+ @Override
+ public void log(Tag tag, String msg) {
+ // Do nothing.
+ }
+
+ @Override
+ public void log(Tag tag, String msg, Throwable tr) {
+ // Do nothing.
+ }
+ };
+
+ private static final Logger LOGGER_D = (!CurrentConfig.get().logDebug() ? SILENT_LOGGER : new Logger() {
+ final int level = android.util.Log.DEBUG;
+
+ @Override
+ public void log(Tag tag, String msg) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.d(tag.toString(), msg);
+ }
+ }
+
+ @Override
+ public void log(Tag tag, String msg, Throwable tr) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.d(tag.toString(), msg, tr);
+ }
+ }
+ });
+
+ private static final Logger LOGGER_E = (!CurrentConfig.get().logError() ? SILENT_LOGGER : new Logger() {
+ final int level = android.util.Log.ERROR;
+
+ @Override
+ public void log(Tag tag, String msg) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.e(tag.toString(), msg);
+ }
+ }
+
+ @Override
+ public void log(Tag tag, String msg, Throwable tr) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.e(tag.toString(), msg, tr);
+ }
+ }
+ });
+
+ private static final Logger LOGGER_I = (!CurrentConfig.get().logInfo() ? SILENT_LOGGER : new Logger() {
+ final int level = android.util.Log.INFO;
+
+ @Override
+ public void log(Tag tag, String msg) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.i(tag.toString(), msg);
+ }
+ }
+
+ @Override
+ public void log(Tag tag, String msg, Throwable tr) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.i(tag.toString(), msg, tr);
+ }
+ }
+ });
+
+ private static final Logger LOGGER_V = (!CurrentConfig.get().logVerbose() ? SILENT_LOGGER : new Logger() {
+ final int level = android.util.Log.VERBOSE;
+
+ @Override
+ public void log(Tag tag, String msg) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.v(tag.toString(), msg);
+ }
+ }
+
+ @Override
+ public void log(Tag tag, String msg, Throwable tr) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.v(tag.toString(), msg, tr);
+ }
+ }
+ });
+
+ private static final Logger LOGGER_W = (!CurrentConfig.get().logWarn() ? SILENT_LOGGER : new Logger() {
+ final int level = android.util.Log.WARN;
+
+ @Override
+ public void log(Tag tag, String msg) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.w(tag.toString(), msg);
+ }
+ }
+
+ @Override
+ public void log(Tag tag, String msg, Throwable tr) {
+ if (isLoggable(tag, level)) {
+ android.util.Log.w(tag.toString(), msg, tr);
+ }
+ }
+ });
+
+
+ public static void d(Tag tag, String msg) {
+ LOGGER_D.log(tag, msg);
+ }
+
+ public static void d(Tag tag, String msg, Throwable tr) {
+ LOGGER_D.log(tag, msg, tr);
+ }
+
+ public static void e(Tag tag, String msg) {
+ LOGGER_E.log(tag, msg);
+ }
+
+ public static void e(Tag tag, String msg, Throwable tr) {
+ LOGGER_E.log(tag, msg, tr);
+ }
+
+ public static void i(Tag tag, String msg) {
+ LOGGER_I.log(tag, msg);
+ }
+
+ public static void i(Tag tag, String msg, Throwable tr) {
+ LOGGER_I.log(tag, msg, tr);
+ }
+
+ public static void v(Tag tag, String msg) {
+ LOGGER_V.log(tag, msg);
+ }
+
+ public static void v(Tag tag, String msg, Throwable tr) {
+ LOGGER_V.log(tag, msg, tr);
+ }
+
+ public static void w(Tag tag, String msg) {
+ LOGGER_W.log(tag, msg);
+ }
+
+ public static void w(Tag tag, String msg, Throwable tr) {
+ LOGGER_W.log(tag, msg, tr);
+ }
+
+ private static boolean isLoggable(Tag tag, int level) {
+ try {
+ return android.util.Log.isLoggable(tag.toString(), level);
+ } catch (IllegalArgumentException ex) {
+ e(TAG, "Tag too long:" + tag);
+ return false;
+ }
+ }
+}