Suspend the VM when it's not visible on the screen
... and resume it when it becomes visible again
Bug: 348552343
Bug: 348380730
Test: play a youtube video in a vm. go back to Android. take some time
and return to the vm. the video resumes at the point it was.
Change-Id: I517c8cf242866df99fe68396417f30bec28ff7dc
Change-Id: I462590eb1cc67b82ef0ef2283e4647f9163af4d0
diff --git a/virtualizationmanager/src/aidl.rs b/virtualizationmanager/src/aidl.rs
index 9df376a..575af6b 100644
--- a/virtualizationmanager/src/aidl.rs
+++ b/virtualizationmanager/src/aidl.rs
@@ -1244,6 +1244,22 @@
fn setHostConsoleName(&self, ptsname: &str) -> binder::Result<()> {
self.instance.vm_context.global_context.setHostConsoleName(ptsname)
}
+
+ fn suspend(&self) -> binder::Result<()> {
+ self.instance
+ .suspend()
+ .with_context(|| format!("Error suspending VM with CID {}", self.instance.cid))
+ .with_log()
+ .or_service_specific_exception(-1)
+ }
+
+ fn resume(&self) -> binder::Result<()> {
+ self.instance
+ .resume()
+ .with_context(|| format!("Error resuming VM with CID {}", self.instance.cid))
+ .with_log()
+ .or_service_specific_exception(-1)
+ }
}
impl Drop for VirtualMachine {