add isHigherBetter flag to the summary report

- Each test should tell if the result is better with higher score or lower score.
- Without this, backend needs to remember which way is better for each test.
- This information should be displayed in visualization / table as well so
  that users do not need to remember which way is better.

Change-Id: I2a54d99e5bc540ee0d0ca4cd1b0ef5f5cb1ebdc5
diff --git a/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java b/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java
index c731cc1..981d46c 100644
--- a/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java
+++ b/suite/pts/deviceTests/dram/src/com/android/pts/dram/BandwidthTest.java
@@ -108,7 +108,7 @@
         // now this represents how many times the whole screen can be copied in a sec.
         double screensPerSecAverage = stat.mAverage / pixels * 1024.0 * 1024.0 / 4.0;
         double screensPerSecStddev = stat.mStddev / pixels * 1024.0 * 1024.0 / 4.0;
-        getReportLog().printSummary("screen copies per sec", screensPerSecAverage,
+        getReportLog().printSummary("screen copies per sec", screensPerSecAverage, true,
                 screensPerSecStddev);
     }
 }
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
index 14fc45a..5831021 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/FileUtil.java
@@ -303,7 +303,7 @@
         report.printArray("Rd amount", rdAmount, true);
         Stat.StatResult stat = Stat.getStat(mbps);
 
-        report.printSummary("MB/s", stat.mAverage, stat.mStddev);
+        report.printSummary("MB/s", stat.mAverage, true, stat.mStddev);
     }
 
     /**
@@ -353,7 +353,7 @@
         report.printArray("Wr amount", wrAmount, true);
         Stat.StatResult stat = Stat.getStat(mbps);
 
-        report.printSummary("MB/s", stat.mAverage, stat.mStddev);
+        report.printSummary("MB/s", stat.mAverage, true, stat.mStddev);
     }
 
     /**
@@ -391,6 +391,6 @@
             ReportLog.copyArray(mbps, mbpsAll, i * numberRepeatInOneRun);
         }
         Stat.StatResult stat = Stat.getStat(mbpsAll);
-        report.printSummary("MB/s", stat.mAverage, stat.mStddev);
+        report.printSummary("MB/s", stat.mAverage, true, stat.mStddev);
     }
 }
diff --git a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
index 252c59e..63539cd 100644
--- a/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
+++ b/suite/pts/deviceTests/filesystemperf/src/com/android/pts/filesystemperf/SequentialRWTest.java
@@ -65,7 +65,7 @@
                 mbps, true);
         getReportLog().printArray("Wr amount", wrAmount, true);
         Stat.StatResult stat = Stat.getStat(mbps);
-        getReportLog().printSummary("MB/s", stat.mAverage, stat.mStddev);
+        getReportLog().printSummary("MB/s", stat.mAverage, true, stat.mStddev);
     }
 
     @TimeoutReq(minutes = 60)
@@ -106,6 +106,6 @@
         getReportLog().printArray("read MB/s",
                 mbps, true);
         Stat.StatResult stat = Stat.getStat(mbps);
-        getReportLog().printSummary("MB/s", stat.mAverage, stat.mStddev);
+        getReportLog().printSummary("MB/s", stat.mAverage, true, stat.mStddev);
     }
 }
diff --git a/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java b/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java
index df8cfd9..b838215 100644
--- a/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java
+++ b/suite/pts/deviceTests/simplecpu/src/com/android/pts/simplecpu/SimpleCpuTest.java
@@ -97,7 +97,7 @@
         }
         getReportLog().printArray("ms", result, false);
         Stat.StatResult stat = Stat.getStat(result);
-        getReportLog().printSummary("ms", stat.mAverage, stat.mStddev);
+        getReportLog().printSummary("ms", stat.mAverage, false, stat.mStddev);
     }
 
     /**
@@ -114,7 +114,7 @@
         }
         getReportLog().printArray("ms", result, false);
         Stat.StatResult stat = Stat.getStat(result);
-        getReportLog().printSummary("ms", stat.mAverage, stat.mStddev);
+        getReportLog().printSummary("ms", stat.mAverage, false, stat.mStddev);
     }
 
 }
diff --git a/suite/pts/deviceTests/ui/src/com/android/pts/ui/FpsTest.java b/suite/pts/deviceTests/ui/src/com/android/pts/ui/FpsTest.java
index 6931e95..80f1022 100644
--- a/suite/pts/deviceTests/ui/src/com/android/pts/ui/FpsTest.java
+++ b/suite/pts/deviceTests/ui/src/com/android/pts/ui/FpsTest.java
@@ -119,6 +119,7 @@
         Log.i(TAG, " fps nominal " + fpsNominal + " fps measured " + fpsMeasured);
         getReportLog().printArray("intervals ms", intervals, false);
         getReportLog().printArray("jankiness ms", jankiness, false);
-        getReportLog().printSummaryFull("Frame interval", " max delay ms", maxDelay, "number of jank", jankNumber);
+        getReportLog().printSummaryFull("Frame interval", " max delay ms", maxDelay, false,
+                "number of jank", jankNumber, false);
     }
 }
diff --git a/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java b/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java
index 8e4bbed..b8e53cb 100644
--- a/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java
+++ b/suite/pts/deviceTests/ui/src/com/android/pts/ui/ScrollingTest.java
@@ -67,6 +67,6 @@
         });
         getReportLog().printArray("ms", results, false);
         Stat.StatResult stat = Stat.getStat(results);
-        getReportLog().printSummary("Time ms", stat.mAverage, stat.mStddev);
+        getReportLog().printSummary("Time ms", stat.mAverage, false, stat.mStddev);
     }
 }
diff --git a/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java b/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
index e78289b..9e6473d 100644
--- a/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
+++ b/suite/pts/hostTests/bootup/src/com/android/pts/bootup/BootupTimeTest.java
@@ -67,7 +67,7 @@
         });
         mReport.printArray("time in ms", result, false);
         StatResult stat = Stat.getStat(result);
-        mReport.printSummary("time in ms", stat.mAverage, stat.mStddev);
+        mReport.printSummary("time in ms", stat.mAverage, false, stat.mStddev);
     }
 
     private void rebootDevice() throws DeviceNotAvailableException {
diff --git a/suite/pts/hostTests/browser/src/com/android/pts/browser/BrowserTest.java b/suite/pts/hostTests/browser/src/com/android/pts/browser/BrowserTest.java
index b5400ab..a92dcb6 100644
--- a/suite/pts/hostTests/browser/src/com/android/pts/browser/BrowserTest.java
+++ b/suite/pts/hostTests/browser/src/com/android/pts/browser/BrowserTest.java
@@ -98,7 +98,7 @@
         }
         mReport.printArray("scores", results, true);
         Stat.StatResult stat = Stat.getStat(results);
-        mReport.printSummary("Score", stat.mAverage, stat.mStddev);
+        mReport.printSummary("Score", stat.mAverage, true, stat.mStddev);
     }
 
     private double runBenchmarking(String testMethodName, String resultPattern,
diff --git a/suite/pts/hostTests/uihost/control/src/com/android/pts/taskswitching/control/TaskswitchingDeviceTest.java b/suite/pts/hostTests/uihost/control/src/com/android/pts/taskswitching/control/TaskswitchingDeviceTest.java
index fc5bc04..e45f9b5 100644
--- a/suite/pts/hostTests/uihost/control/src/com/android/pts/taskswitching/control/TaskswitchingDeviceTest.java
+++ b/suite/pts/hostTests/uihost/control/src/com/android/pts/taskswitching/control/TaskswitchingDeviceTest.java
@@ -83,7 +83,7 @@
         });
         getReportLog().printArray("ms", results, false);
         Stat.StatResult stat = Stat.getStat(results);
-        getReportLog().printSummary("Time ms", stat.mAverage, stat.mStddev);
+        getReportLog().printSummary("Time ms", stat.mAverage, false, stat.mStddev);
     }
 
     private void startActivity(String packageName, String activityName) {
diff --git a/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java b/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java
index 4bfcde1..ccb46db 100644
--- a/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java
+++ b/suite/pts/hostTests/uihost/src/com/android/pts/uihost/InstallTimeTest.java
@@ -91,7 +91,7 @@
         });
         mReport.printArray("time in ms", result, false);
         StatResult stat = Stat.getStat(result);
-        mReport.printSummary("time in ms", stat.mAverage, stat.mStddev);
+        mReport.printSummary("time in ms", stat.mAverage, false, stat.mStddev);
     }
 
 }
diff --git a/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java b/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
index 90eed82..cca7c26 100644
--- a/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
+++ b/suite/pts/lib/commonutil/src/com/android/pts/util/ReportLog.java
@@ -76,11 +76,12 @@
      * For standard report summary with average and stddev
      * @param header
      * @param average
+     * @param tells if average with higher score is better or not (lower better for false)
      * @param stddev
      */
-    public void printSummary(String header, double average, double stddev) {
-        mSummary = header + LOG_ELEM_SEPARATOR + "average " + average + LOG_ELEM_SEPARATOR +
-                "stddev " + stddev;
+    public void printSummary(String header, double average, boolean isHigherBetter, double stddev) {
+        mSummary = header + LOG_ELEM_SEPARATOR + "average " + average +  " " +
+        boolToInt(isHigherBetter) + LOG_ELEM_SEPARATOR + "stddev " + stddev + " 0";
     }
 
     /**
@@ -88,12 +89,16 @@
      * @param header
      * @param key1 String key for val1
      * @param val1
+     * @param val1HigherBetter higher score is better for val1
      * @param key2 String key for val2
      * @param val2
+     * @param val2HigherBetter higher score is better for val2
      */
-    public void printSummaryFull(String header, String key1, double val1, String key2, double val2) {
-        mSummary = header + LOG_ELEM_SEPARATOR + key1 + " " + val1 + LOG_ELEM_SEPARATOR +
-                key2 + " " + val2;
+    public void printSummaryFull(String header, String key1, double val1, boolean val1HigherBetter,
+            String key2, double val2, boolean val2HigherBetter) {
+        mSummary = header + LOG_ELEM_SEPARATOR + key1 + " " + val1 + " " +
+            boolToInt(val1HigherBetter) + LOG_ELEM_SEPARATOR + key2 + " " + val2 + " " +
+            boolToInt(val2HigherBetter);
     }
 
     public void throwReportToHost() throws PtsException {
@@ -179,6 +184,13 @@
         return names;
     }
 
+    private static int boolToInt(boolean val) {
+        if (val) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
     /**
      * to be overridden by child to print message to be passed
      * @param msg