summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-10-17 13:50:19 -0700
committerMark Wei <markwei@google.com>2013-10-17 14:53:08 -0700
commit9d46a01e044696eb4d101778992fed4966520251 (patch)
tree495affc5d7539289c33e7377916e47a8c881d4d8 /src/com
parent25ad6f98516a7af1ca71cfa07fb503d46dc8a7f1 (diff)
downloadbitmap-9d46a01e044696eb4d101778992fed4966520251.tar.gz
Trace without reflection. Avoid crashing on ICS.
Change-Id: Ic75143a38d252278329a6f775c137ff1321eaf28
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/bitmap/util/Trace.java55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/com/android/bitmap/util/Trace.java b/src/com/android/bitmap/util/Trace.java
index e303d72..63d02cd 100644
--- a/src/com/android/bitmap/util/Trace.java
+++ b/src/com/android/bitmap/util/Trace.java
@@ -16,45 +16,36 @@
package com.android.bitmap.util;
-import java.lang.reflect.Method;
+import android.os.Build;
-public class Trace {
-
- private static Method sBegin;
- private static Method sEnd;
-
- public static void init() {
- if (sBegin != null && sEnd != null) {
- return;
- }
- try {
- final Class<?> cls = Class.forName("android.os.Trace");
- sBegin = cls.getMethod("beginSection", String.class);
- sEnd = cls.getMethod("endSection");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+/**
+ * Stand-in for {@link android.os.Trace}.
+ */
+public abstract class Trace {
+ /**
+ * Begins systrace tracing for a given tag. No-op on unsupported platform versions.
+ *
+ * @param tag systrace tag to use
+ *
+ * @see android.os.Trace#beginSection(String)
+ */
public static void beginSection(String tag) {
- if (sBegin == null) {
- return;
- }
- try {
- sBegin.invoke(null, tag);
- } catch (Exception e) {
- e.printStackTrace();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ android.os.Trace.beginSection(tag);
}
}
+ /**
+ * Ends systrace tracing for the most recently begun section. No-op on unsupported platform
+ * versions.
+ *
+ * @see android.os.Trace#endSection()
+ */
public static void endSection() {
- if (sEnd == null) {
- return;
- }
- try {
- sEnd.invoke(null, (Object[]) null);
- } catch (Exception e) {
- e.printStackTrace();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ android.os.Trace.endSection();
}
}
+
}