Merge "Prepare diced before microdroid_manager runs"
diff --git a/compos/aidl/com/android/compos/FdAnnotation.aidl b/compos/aidl/com/android/compos/FdAnnotation.aidl
deleted file mode 100644
index b910391..0000000
--- a/compos/aidl/com/android/compos/FdAnnotation.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.compos;
-
-/** {@hide} */
-parcelable FdAnnotation {
-    /**
-     * Input file descriptor numbers to be passed to the program.  This is currently assumed to be
-     * same as the file descriptor number used in the backend server.
-     */
-    int[] input_fds;
-
-    /**
-     * Output file descriptor numbers to be passed to the program.  This is currently assumed to be
-     * same as the file descriptor number used in the backend server.
-     */
-    int[] output_fds;
-}
diff --git a/compos/aidl/com/android/compos/ICompOsService.aidl b/compos/aidl/com/android/compos/ICompOsService.aidl
index b2b961a..39e9d61 100644
--- a/compos/aidl/com/android/compos/ICompOsService.aidl
+++ b/compos/aidl/com/android/compos/ICompOsService.aidl
@@ -17,7 +17,6 @@
 package com.android.compos;
 
 import com.android.compos.CompOsKeyData;
-import com.android.compos.FdAnnotation;
 
 /** {@hide} */
 interface ICompOsService {
@@ -51,21 +50,6 @@
             String zygoteArch, String systemServerCompilerFilter);
 
     /**
-     * Runs dexopt compilation encoded in the marshaled dexopt arguments.
-     *
-     * To keep ART indepdendantly updatable, the compilation arguments are not stabilized. As a
-     * result, the arguments are marshaled into byte array.  Upon received, the service asks ART to
-     * return relevant information (since ART is able to unmarshal its own encoding), in order to
-     * set up the execution context (mainly file descriptors for compiler input and output) then
-     * invokes the compiler.
-     *
-     * @param marshaledArguments The marshaled dexopt arguments.
-     * @param fd_annotation Additional file descriptor information of the execution.
-     * @return exit code
-     */
-    byte compile(in byte[] marshaledArguments, in FdAnnotation fd_annotation);
-
-    /**
      * Generate a new public/private key pair suitable for signing CompOs output files.
      *
      * @return a certificate for the public key and the encrypted private key
diff --git a/compos/common/compos_client.rs b/compos/common/compos_client.rs
index b54a921..f4b3440 100644
--- a/compos/common/compos_client.rs
+++ b/compos/common/compos_client.rs
@@ -46,6 +46,9 @@
 use std::sync::{Arc, Condvar, Mutex};
 use std::thread;
 
+// Enough memory to complete odrefresh in the VM.
+const VM_MEMORY_MIB: i32 = 1024;
+
 /// This owns an instance of the CompOS VM.
 pub struct VmInstance {
     #[allow(dead_code)] // Keeps the VM alive even if we don`t touch it
@@ -119,9 +122,9 @@
             configPath: config_path.to_owned(),
             debugLevel: debug_level,
             extraIdsigs: vec![idsig_manifest_apk_fd],
+            memoryMib: VM_MEMORY_MIB,
             numCpus: parameters.cpus.map_or(1, NonZeroU32::get) as i32,
             cpuAffinity: parameters.cpu_set.clone(),
-            ..Default::default()
         });
 
         let vm = service
diff --git a/compos/compos_key_cmd/compos_key_cmd.cpp b/compos/compos_key_cmd/compos_key_cmd.cpp
index 8ed07e6..4312a5a 100644
--- a/compos/compos_key_cmd/compos_key_cmd.cpp
+++ b/compos/compos_key_cmd/compos_key_cmd.cpp
@@ -73,6 +73,8 @@
 
 constexpr unsigned int kRpcPort = 6432;
 
+constexpr int kVmMemoryMib = 1024;
+
 constexpr const char* kConfigApkPath =
         "/apex/com.android.compos/app/CompOSPayloadApp/CompOSPayloadApp.apk";
 
@@ -279,7 +281,7 @@
         appConfig.configPath = mPreferStaged ? kPreferStagedConfigFilePath : kDefaultConfigFilePath;
         appConfig.debugLevel = mDebuggable ? VirtualMachineAppConfig::DebugLevel::FULL
                                            : VirtualMachineAppConfig::DebugLevel::NONE;
-        appConfig.memoryMib = 0; // Use default
+        appConfig.memoryMib = kVmMemoryMib;
 
         LOG(INFO) << "Starting VM";
         auto status = service->createVm(config, logFd, logFd, &mVm);
diff --git a/compos/src/compsvc.rs b/compos/src/compsvc.rs
index 356cc7e..b4af9b5 100644
--- a/compos/src/compsvc.rs
+++ b/compos/src/compsvc.rs
@@ -32,7 +32,6 @@
 use authfs_aidl_interface::aidl::com::android::virt::fs::IAuthFsService::IAuthFsService;
 use compos_aidl_interface::aidl::com::android::compos::{
     CompOsKeyData::CompOsKeyData,
-    FdAnnotation::FdAnnotation,
     ICompOsService::{BnCompOsService, ICompOsService},
 };
 use compos_aidl_interface::binder::{
@@ -113,10 +112,6 @@
         Ok(exit_code as i8)
     }
 
-    fn compile(&self, _marshaled: &[u8], _fd_annotation: &FdAnnotation) -> BinderResult<i8> {
-        Err(new_binder_exception(ExceptionCode::UNSUPPORTED_OPERATION, "Not yet implemented"))
-    }
-
     fn generateSigningKey(&self) -> BinderResult<CompOsKeyData> {
         to_binder_result(self.key_service.generate())
     }
diff --git a/microdroid_manager/src/payload.rs b/microdroid_manager/src/payload.rs
index 8ec6f74..b731d33 100644
--- a/microdroid_manager/src/payload.rs
+++ b/microdroid_manager/src/payload.rs
@@ -14,6 +14,8 @@
 
 //! Routines for handling payload
 
+mod apex;
+
 use crate::instance::ApexData;
 use crate::ioutil::wait_for_file;
 use anyhow::Result;
@@ -61,5 +63,3 @@
         ..Default::default()
     }
 }
-
-mod apex;
diff --git a/statslog_virtualization/Android.bp b/statslog_virtualization/Android.bp
index 846d12b..51a51a3 100644
--- a/statslog_virtualization/Android.bp
+++ b/statslog_virtualization/Android.bp
@@ -14,6 +14,10 @@
 // limitations under the License.
 
 // Autogenerate the class (and respective headers) with logging methods and constants
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
 genrule {
     name: "statslog_virtualization_header.rs",
     tools: ["stats-log-api-gen"],
diff --git a/virtualizationservice/src/payload.rs b/virtualizationservice/src/payload.rs
index a8c22cd..84d3b2f 100644
--- a/virtualizationservice/src/payload.rs
+++ b/virtualizationservice/src/payload.rs
@@ -374,6 +374,7 @@
 #[cfg(test)]
 mod tests {
     use super::*;
+
     #[test]
     fn test_find_apex_names_in_classpath() {
         let vars = r#"
@@ -387,4 +388,35 @@
 
         assert_eq!(find_apex_names_in_classpath(vars).unwrap(), expected);
     }
+
+    #[test]
+    fn test_collect_apex_names() {
+        let apex_list = ApexInfoList {
+            list: vec![
+                ApexInfo {
+                    name: "hasnt_classpath".to_string(),
+                    path: PathBuf::from("path0"),
+                    has_classpath_jar: false,
+                },
+                ApexInfo {
+                    name: "has_classpath".to_string(),
+                    path: PathBuf::from("path1"),
+                    has_classpath_jar: true,
+                },
+            ],
+        };
+        let apexes = vec![
+            ApexConfig { name: "config_name".to_string() },
+            ApexConfig { name: "{CLASSPATH}".to_string() },
+        ];
+        assert_eq!(
+            collect_apex_names(&apex_list, &apexes, DebugLevel::FULL),
+            vec![
+                "com.android.adbd".to_string(),
+                "com.android.os.statsd".to_string(),
+                "config_name".to_string(),
+                "has_classpath".to_string(),
+            ]
+        );
+    }
 }