Pass isFactory bit from host to Microdroid via payload metadata
The isolated compilation usecase demands that isFactory bit of an APEX
is the same across VM and host. This is because the bit is encoded in
the compiled artifact (in the VM), and matched against the same bit on
the host side.
This is now done by (1) reading isFactory bit from
/apex/apex-info-list.xml and (2) send the bit to the VM by writing it to
payload metadata. (3) On the VM side, apexd records the bit to
/apex/apex-info-list.xml. (See the other CL in the same topic for the
last step).
Bug: 210998761
Test: adb shell /apex/com.android.compos/bin/composd_cmd staged-apex-compile
Change-Id: I69dd73357132812766867db13f0f5cb9958bb113
Test: (1) build any APEX (e.g. com.android.virt) and install it
(2) add the name of the APEX to vm_config.json of the test app.
(3) run the test app and adb shell into the VM
(4) check /apex/apex-info-list.xml has isFactory="false" for the apex.
Change-Id: Iaed1e2c9b232a6e9a58a0624adb5044d06d88d2b
diff --git a/microdroid/payload/metadata.proto b/microdroid/payload/metadata.proto
index 9e60b38..2e92f55 100644
--- a/microdroid/payload/metadata.proto
+++ b/microdroid/payload/metadata.proto
@@ -43,6 +43,10 @@
// The timestamp in seconds when the APEX was last updated. This should match the value in
// apex-info-list.xml.
uint64 last_update_seconds = 5;
+
+ // Required.
+ // Whether the APEX is a factory version or not.
+ bool is_factory = 6;
}
message ApkPayload {
diff --git a/microdroid_manager/src/instance.rs b/microdroid_manager/src/instance.rs
index 1068792..5a77198 100644
--- a/microdroid_manager/src/instance.rs
+++ b/microdroid_manager/src/instance.rs
@@ -336,4 +336,5 @@
pub public_key: Vec<u8>,
pub root_digest: Vec<u8>,
pub last_update_seconds: u64,
+ pub is_factory: bool,
}
diff --git a/microdroid_manager/src/payload.rs b/microdroid_manager/src/payload.rs
index 661af5f..48535f3 100644
--- a/microdroid_manager/src/payload.rs
+++ b/microdroid_manager/src/payload.rs
@@ -48,6 +48,7 @@
public_key: result.public_key,
root_digest: result.root_digest,
last_update_seconds: apex.last_update_seconds,
+ is_factory: apex.is_factory,
})
})
.collect()
@@ -63,6 +64,7 @@
public_key: data.public_key.clone(),
root_digest: data.root_digest.clone(),
last_update_seconds: data.last_update_seconds,
+ is_factory: data.is_factory,
..Default::default()
})
.collect(),
diff --git a/virtualizationservice/src/payload.rs b/virtualizationservice/src/payload.rs
index 65adc25..e4a763c 100644
--- a/virtualizationservice/src/payload.rs
+++ b/virtualizationservice/src/payload.rs
@@ -66,6 +66,9 @@
// The field claims to be milliseconds but is actually seconds.
#[serde(rename = "lastUpdateMillis")]
last_update_seconds: u64,
+
+ #[serde(rename = "isFactory")]
+ is_factory: bool,
}
impl ApexInfoList {
@@ -137,6 +140,8 @@
let metadata = metadata(&apex_info.path)?;
apex_info.last_update_seconds =
metadata.modified()?.duration_since(SystemTime::UNIX_EPOCH)?.as_secs();
+ // by definition, staged apex can't be a factory apex.
+ apex_info.is_factory = false;
}
}
}
@@ -158,10 +163,12 @@
.iter()
.enumerate()
.map(|(i, apex_name)| {
+ let apex_info = apex_list.get(apex_name)?;
Ok(ApexPayload {
name: apex_name.clone(),
partition_name: format!("microdroid-apex-{}", i),
- last_update_seconds: apex_list.get(apex_name)?.last_update_seconds,
+ last_update_seconds: apex_info.last_update_seconds,
+ is_factory: apex_info.is_factory,
..Default::default()
})
})
@@ -411,12 +418,14 @@
path: PathBuf::from("path0"),
has_classpath_jar: false,
last_update_seconds: 12345678,
+ is_factory: true,
},
ApexInfo {
name: "has_classpath".to_string(),
path: PathBuf::from("path1"),
has_classpath_jar: true,
last_update_seconds: 87654321,
+ is_factory: false,
},
],
};