Disable GfxMonitor on pre-M platforms.

Change-Id: Id72b05c57e019c3cacd57df4fbbe6f5f0160e45b
diff --git a/src/main/java/android/support/test/jank/internal/JankMonitorFactory.java b/src/main/java/android/support/test/jank/internal/JankMonitorFactory.java
index 9c25262..55f940d 100644
--- a/src/main/java/android/support/test/jank/internal/JankMonitorFactory.java
+++ b/src/main/java/android/support/test/jank/internal/JankMonitorFactory.java
@@ -17,9 +17,11 @@
 package android.support.test.jank.internal;
 
 import android.app.UiAutomation;
+import android.os.Build;
 import android.support.test.jank.WindowAnimationFrameStatsMonitor;
 import android.support.test.jank.WindowContentFrameStatsMonitor;
 import android.support.test.jank.GfxMonitor;
+import android.util.Log;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -27,6 +29,11 @@
 
 public class JankMonitorFactory {
 
+    private static String TAG = "JankTestHelper";
+
+    static final int API_LEVEL_ACTUAL = Build.VERSION.SDK_INT
+            + ("REL".equals(Build.VERSION.CODENAME) ? 0 : 1);
+
     private UiAutomation mUiAutomation;
 
     public JankMonitorFactory(UiAutomation automation) {
@@ -36,8 +43,13 @@
     public List<JankMonitor> getJankMonitors(Method testMethod) {
         List<JankMonitor> monitors = new ArrayList<JankMonitor>();
         if (testMethod.getAnnotation(GfxMonitor.class) != null) {
-            String process = testMethod.getAnnotation(GfxMonitor.class).processName();
-            monitors.add(new GfxMonitorImpl(mUiAutomation, process));
+            // GfxMonitor only works on M+. NB: Hard coding value since SDK 22 isn't in prebuilts.
+            if (API_LEVEL_ACTUAL <= 22) {
+                Log.w(TAG, "Skipping GfxMonitor. Not supported by current platform.");
+            } else {
+                String process = testMethod.getAnnotation(GfxMonitor.class).processName();
+                monitors.add(new GfxMonitorImpl(mUiAutomation, process));
+            }
         }
         if (testMethod.getAnnotation(WindowContentFrameStatsMonitor.class) != null) {
             monitors.add(new WindowContentFrameStatsMonitorImpl(mUiAutomation));