Add a command to print package dexopt status.

Can be invoked like so :

$adb shell dumpsys package dexopt
$adb shell dumpsys package dexopt <packageName>

bug: 27494108
Change-Id: Ie91f744aeac772e0e22abc9c805df9290a4e2418
diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
index f134e40..89747b5 100644
--- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java
+++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java
@@ -28,6 +28,7 @@
 import android.util.Slog;
 
 import com.android.internal.os.InstallerConnection.InstallerException;
+import com.android.internal.util.IndentingPrintWriter;
 
 import java.io.File;
 import java.io.IOException;
@@ -122,6 +123,32 @@
         return dexoptFlags;
     }
 
+    /**
+     * Dumps the dexopt state of the given package {@code pkg} to the given {@code PrintWriter}.
+     */
+    void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg) {
+        final String[] instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
+        final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);
+
+        final List<String> paths = pkg.getAllCodePathsExcludingResourceOnly();
+
+        for (String instructionSet : dexCodeInstructionSets) {
+             pw.println("Instruction Set: " + instructionSet);
+             pw.increaseIndent();
+             for (String path : paths) {
+                  String status = null;
+                  try {
+                      status = DexFile.getDexFileStatus(path, instructionSet);
+                  } catch (IOException ioe) {
+                      status = "[Exception]: " + ioe.getMessage();
+                  }
+                  pw.println("path: " + path);
+                  pw.println("status: " + status);
+             }
+             pw.decreaseIndent();
+        }
+    }
+
     private int performDexOptLI(PackageParser.Package pkg, String[] sharedLibraries,
             String[] targetInstructionSets, boolean checkProfiles, String targetCompilerFilter) {
         final String[] instructionSets = targetInstructionSets != null ?