Snap for 4693621 from 2e47353635cbcc91127f350eb57d80634ae7ccac to pi-release
Change-Id: I77947bc71e19ad32f860af8a48dc3bb3cde224b5
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;
/**
diff --git a/libart/src/main/java/dalvik/system/VMRuntime.java b/libart/src/main/java/dalvik/system/VMRuntime.java
index 737de65..8c80346 100644
--- a/libart/src/main/java/dalvik/system/VMRuntime.java
+++ b/libart/src/main/java/dalvik/system/VMRuntime.java
@@ -20,6 +20,7 @@
import java.lang.ref.FinalizerReference;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.Consumer;
/**
* Provides an interface to VM-global, Dalvik-specific features.
@@ -59,6 +60,8 @@
*/
public static final int SDK_VERSION_CUR_DEVELOPMENT = 10000;
+ private static Consumer<String> nonSdkApiUsageConsumer = null;
+
private int targetSdkVersion = SDK_VERSION_CUR_DEVELOPMENT;
/**
@@ -265,6 +268,15 @@
public native boolean hasUsedHiddenApi();
/**
+ * Sets the list of exemptions from hidden API access enforcement.
+ *
+ * @param signaturePrefixes
+ * A list of signature prefixes. Each item in the list is a prefix match on the type
+ * signature of a blacklisted API. Access is permitted to any matching API.
+ */
+ public native void setHiddenApiExemptions(String[] signaturePrefixes);
+
+ /**
* Returns an array allocated in an area of the Java heap where it will never be moved.
* This is used to implement native allocations on the Java heap, such as DirectByteBuffers
* and Bitmaps.
@@ -432,4 +444,11 @@
* Sets up the priority of the system daemon thread (caller).
*/
public static native void setSystemDaemonThreadPriority();
+
+ /**
+ * Sets a callback that the runtime can call whenever a usage of a non SDK API is detected.
+ */
+ public static void setNonSdkApiUsageConsumer(Consumer<String> consumer) {
+ nonSdkApiUsageConsumer = consumer;
+ }
}