Add VMRuntime.getTargetSdkVersion.
The goal is to enable libcore to adjust its behavior based on the
target SDK version / API Level of the app.
Change-Id: I60f1febc1f8ddf2a97925a48ddf232508d5c44f9
diff --git a/libart/src/main/java/dalvik/system/VMRuntime.java b/libart/src/main/java/dalvik/system/VMRuntime.java
index af900c8..063a988 100644
--- a/libart/src/main/java/dalvik/system/VMRuntime.java
+++ b/libart/src/main/java/dalvik/system/VMRuntime.java
@@ -30,6 +30,8 @@
*/
private static final VMRuntime THE_ONE = new VMRuntime();
+ private int targetSdkVersion;
+
/**
* Prevents this class from being instantiated.
*/
@@ -116,9 +118,23 @@
* app starts to run, because it may change the VM's behavior in
* dangerous ways. Use 0 to mean "current" (since callers won't
* necessarily know the actual current SDK version, and the
- * allocated version numbers start at 1).
+ * allocated version numbers start at 1), and 10000 to mean
+ * CUR_DEVELOPMENT.
*/
- public native void setTargetSdkVersion(int targetSdkVersion);
+ public synchronized void setTargetSdkVersion(int targetSdkVersion) {
+ this.targetSdkVersion = targetSdkVersion;
+ setTargetSdkVersionNative(this.targetSdkVersion);
+ }
+
+ /**
+ * Gets the target SDK version. See {@link #setTargetSdkVersion} for
+ * special values.
+ */
+ public synchronized int getTargetSdkVersion() {
+ return targetSdkVersion;
+ }
+
+ private native void setTargetSdkVersionNative(int targetSdkVersion);
/**
* This method exists for binary compatibility. It was part of a