Update registerAppInfo signatures to accomodate more data.

Test: m
Bug: 182793486
Bug: 185979271
Change-Id: Ib92327e39bad5914d48ae8a37dd4b5092c5e1407
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index a483ae7..1590c9c 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -364,13 +364,17 @@
 }
 
 /*
- * This is called by the framework when it knows the application directory and
- * process name.
+ * This is called by the framework after it loads a code path on behalf of the app.
+ * The code_path_type indicates the type of the apk being loaded and can be used
+ * for more precise telemetry (e.g. is the split apk odex up to date?) and debugging.
  */
 static void VMRuntime_registerAppInfo(JNIEnv* env,
                                       jclass clazz ATTRIBUTE_UNUSED,
-                                      jstring profile_file,
-                                      jobjectArray code_paths) {
+                                      jstring package_name ATTRIBUTE_UNUSED,
+                                      jstring cur_profile_file,
+                                      jstring ref_profile_file ATTRIBUTE_UNUSED,
+                                      jobjectArray code_paths,
+                                      jint code_path_type ATTRIBUTE_UNUSED) {
   std::vector<std::string> code_paths_vec;
   int code_paths_length = env->GetArrayLength(code_paths);
   for (int i = 0; i < code_paths_length; i++) {
@@ -380,11 +384,11 @@
     env->ReleaseStringUTFChars(code_path, raw_code_path);
   }
 
-  const char* raw_profile_file = env->GetStringUTFChars(profile_file, nullptr);
-  std::string profile_file_str(raw_profile_file);
-  env->ReleaseStringUTFChars(profile_file, raw_profile_file);
+  const char* raw_cur_profile_file = env->GetStringUTFChars(cur_profile_file, nullptr);
+  std::string cur_profile_file_str(raw_cur_profile_file);
+  env->ReleaseStringUTFChars(cur_profile_file, raw_cur_profile_file);
 
-  Runtime::Current()->RegisterAppInfo(code_paths_vec, profile_file_str);
+  Runtime::Current()->RegisterAppInfo(code_paths_vec, cur_profile_file_str);
 }
 
 static jboolean VMRuntime_isBootClassPathOnDisk(JNIEnv* env, jclass, jstring java_instruction_set) {
@@ -526,7 +530,8 @@
   FAST_NATIVE_METHOD(VMRuntime, is64Bit, "()Z"),
   FAST_NATIVE_METHOD(VMRuntime, isCheckJniEnabled, "()Z"),
   NATIVE_METHOD(VMRuntime, preloadDexCaches, "()V"),
-  NATIVE_METHOD(VMRuntime, registerAppInfo, "(Ljava/lang/String;[Ljava/lang/String;)V"),
+  NATIVE_METHOD(VMRuntime, registerAppInfo,
+      "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;I)V"),
   NATIVE_METHOD(VMRuntime, isBootClassPathOnDisk, "(Ljava/lang/String;)Z"),
   NATIVE_METHOD(VMRuntime, getCurrentInstructionSet, "()Ljava/lang/String;"),
   NATIVE_METHOD(VMRuntime, setSystemDaemonThreadPriority, "()V"),
diff --git a/test/2230-profile-save-hotness/src-art/Main.java b/test/2230-profile-save-hotness/src-art/Main.java
index b792adf..f71a891 100644
--- a/test/2230-profile-save-hotness/src-art/Main.java
+++ b/test/2230-profile-save-hotness/src-art/Main.java
@@ -38,7 +38,12 @@
     try {
       file = createTempFile();
       String codePath = System.getenv("DEX_LOCATION") + "/2230-profile-save-hotness.jar";
-      VMRuntime.registerAppInfo(file.getPath(), new String[] {codePath});
+      VMRuntime.registerAppInfo(
+          "test.app",
+          file.getPath(),
+          file.getPath(),
+          new String[] {codePath},
+          VMRuntime.CODE_PATH_TYPE_PRIMARY_APK);
 
       // Test that the profile saves an app method with a profiling info.
       $noinline$hotnessCountWithLoop(10000);
diff --git a/test/595-profile-saving/src/Main.java b/test/595-profile-saving/src/Main.java
index d9d4981..e693006 100644
--- a/test/595-profile-saving/src/Main.java
+++ b/test/595-profile-saving/src/Main.java
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
@@ -27,8 +28,11 @@
       file = createTempFile();
       // String codePath = getDexBaseLocation();
       String codePath = System.getenv("DEX_LOCATION") + "/595-profile-saving.jar";
-      VMRuntime.registerAppInfo(file.getPath(),
-                                new String[] {codePath});
+      VMRuntime.registerAppInfo("test.app",
+                                file.getPath(),
+                                file.getPath(),
+                                new String[] {codePath},
+                                VMRuntime.CODE_PATH_TYPE_PRIMARY_APK);
 
       // Test that the profile saves an app method with a profiling info.
       Method appMethod = Main.class.getDeclaredMethod("testAddMethodToProfile",
@@ -91,20 +95,32 @@
   }
 
   private static class VMRuntime {
+    public static final int CODE_PATH_TYPE_PRIMARY_APK = 1;
     private static final Method registerAppInfoMethod;
+
     static {
       try {
         Class<? extends Object> c = Class.forName("dalvik.system.VMRuntime");
         registerAppInfoMethod = c.getDeclaredMethod("registerAppInfo",
-            String.class, String[].class);
+            String.class, String.class, String.class, String[].class, int.class);
       } catch (Exception e) {
         throw new RuntimeException(e);
       }
     }
 
-    public static void registerAppInfo(String profile, String[] codePaths)
-        throws Exception {
-      registerAppInfoMethod.invoke(null, profile, codePaths);
+    public static void registerAppInfo(
+        String packageName,
+        String curProfile,
+        String refProfile,
+        String[] codePaths,
+        int codePathsType) throws Exception {
+      registerAppInfoMethod.invoke(
+          null,
+          packageName,
+          curProfile,
+          refProfile,
+          codePaths,
+          codePathsType);
     }
   }
 }