Add support for selecting alternate JDWP implementations

Change the '-Xagentlib:jdwp=...' option to instead use the new
'-XjdwpOptions:...' syntax and remove the explicit transport-lib.

Add a '-XjdwpProvider:...' option. Set it to 'default' by default and
get its value from the 'dalvik.vm.jdwp-provider' property.

Test: Boots. Can debug apps
Test: Set dalvik.vm.jdwp-provider=adbconnection, stop, start, debug

Bug: 62821960
Change-Id: I1605030b94b38676c18885fcf2fa3490bccd3e0d
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 9059862..dc29d4c 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -643,6 +643,7 @@
     char methodTraceFileBuf[sizeof("-Xmethod-trace-file:") + PROPERTY_VALUE_MAX];
     char methodTraceFileSizeBuf[sizeof("-Xmethod-trace-file-size:") + PROPERTY_VALUE_MAX];
     std::string fingerprintBuf;
+    char jdwpProviderBuf[sizeof("-XjdwpProvider:") - 1 + PROPERTY_VALUE_MAX];
 
     bool checkJni = false;
     property_get("dalvik.vm.checkjni", propBuf, "");
@@ -765,9 +766,15 @@
      * Set suspend=y to pause during VM init and use android ADB transport.
      */
     if (zygote) {
-      addOption("-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y");
+      addOption("-XjdwpOptions:suspend=n,server=y");
     }
 
+    // Set the JDWP provider. By default let the runtime choose.
+    parseRuntimeOption("dalvik.vm.jdwp-provider",
+                       jdwpProviderBuf,
+                       "-XjdwpProvider:",
+                       "default");
+
     parseRuntimeOption("dalvik.vm.lockprof.threshold",
                        lockProfThresholdBuf,
                        "-Xlockprofthreshold:");