Merge "Encapsulate the optimization info for a dex file in its own class" into pi-dev
diff --git a/dalvik/src/main/java/dalvik/system/DexFile.java b/dalvik/src/main/java/dalvik/system/DexFile.java
index 1b5309e..b677c2a 100644
--- a/dalvik/src/main/java/dalvik/system/DexFile.java
+++ b/dalvik/src/main/java/dalvik/system/DexFile.java
@@ -17,13 +17,11 @@
 package dalvik.system;
 
 import android.system.ErrnoException;
-import android.system.StructStat;
 import dalvik.annotation.optimization.ReachabilitySensitive;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.List;
@@ -519,6 +517,46 @@
         throws FileNotFoundException;
 
     /**
+     * Encapsulates information about the optimizations performed on a dex file.
+     *
+     * Note that the info is only meant for debugging and is not guaranteed to be
+     * stable across releases and/or devices.
+     *
+     * @hide
+     */
+    public static final class OptimizationInfo {
+        // The optimization status.
+        private final String status;
+        // The optimization reason. The reason might be "unknown" if the
+        // the compiler artifacts were not annotated during optimizations.
+        private final String reason;
+
+        private OptimizationInfo(String status, String reason) {
+            this.status = status;
+            this.reason = reason;
+        }
+
+        public String getStatus() {
+            return status;
+        }
+
+        public String getReason() {
+            return reason;
+        }
+    }
+
+    /**
+     * Retrieves the optimization info for a dex file.
+     *
+     * @hide
+     */
+    public static OptimizationInfo getDexFileOptimizationInfo(
+            String fileName, String instructionSet) throws FileNotFoundException {
+        String[] status = getDexFileOptimizationStatus(fileName, instructionSet);
+        return new OptimizationInfo(status[0], status[1]);
+    }
+
+    /**
      * Returns the optimization status of the dex file {@code fileName}. The returned
      * array will have 2 elements which specify:
      *   - index 0: the level of optimizations
@@ -530,7 +568,7 @@
      *
      * @hide
      */
-    public static native String[] getDexFileOptimizationStatus(
+    private static native String[] getDexFileOptimizationStatus(
             String fileName, String instructionSet) throws FileNotFoundException;
 
     /**