summaryrefslogtreecommitdiffstats
path: root/gallerycommon
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2011-09-27 20:14:34 +0800
committerOwen Lin <owenlin@google.com>2011-09-29 15:35:03 +0800
commit464b66583c0d455d1e1c407f1128545060821688 (patch)
treee0185b8b7c6bc4e051c08280adb6c461722c6864 /gallerycommon
parenta0ab2da9f8df41bf4b59fe85c8982ff06d2a659a (diff)
downloadandroid_packages_apps_Snap-464b66583c0d455d1e1c407f1128545060821688.tar.gz
android_packages_apps_Snap-464b66583c0d455d1e1c407f1128545060821688.tar.bz2
android_packages_apps_Snap-464b66583c0d455d1e1c407f1128545060821688.zip
Add maskDebugInfo to display info for debugging build only.
bug: 5335366 Change-Id: I5b6de536bb8e9439b61eb3778fbb1801c8e898c8
Diffstat (limited to 'gallerycommon')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/Utils.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/Utils.java b/gallerycommon/src/com/android/gallery3d/common/Utils.java
index 78449ae6b..ea289a628 100644
--- a/gallerycommon/src/com/android/gallery3d/common/Utils.java
+++ b/gallerycommon/src/com/android/gallery3d/common/Utils.java
@@ -42,6 +42,11 @@ public class Utils {
private static long[] sCrcTable = new long[256];
+ private static final boolean IS_DEBUG_BUILD =
+ Build.TYPE.equals("eng") || Build.TYPE.equals("userdebug");
+
+ private static final String MASK_STRING = "********************************";
+
// Throws AssertionError if the input is false.
public static void assertTrue(boolean cond) {
if (!cond) {
@@ -402,4 +407,14 @@ public class Utils {
if (parcel != null) parcel.recycle();
}
}
+
+ // Mask information for debugging only. It returns <code>info.toString()</code> directly
+ // for debugging build (i.e., 'eng' and 'userdebug') and returns a mask ("****")
+ // in release build to protect the information (e.g. for privacy issue).
+ public static String maskDebugInfo(Object info) {
+ if (info == null) return null;
+ String s = info.toString();
+ int length = Math.min(s.length(), MASK_STRING.length());
+ return IS_DEBUG_BUILD ? s : MASK_STRING.substring(0, length);
+ }
}