Merge "Import translations. DO NOT MERGE ANYWHERE" into main
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
index 1442d30..bfa425d 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.java
@@ -300,6 +300,8 @@
.setVisibility(View.VISIBLE);
mBootCompleted.open();
updateModifierKeysVisibility();
+ mWebView.evaluateJavascript(
+ TerminalView.TOUCH_TO_MOUSE_HANDLER, null);
}
}
});
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/TerminalView.java b/android/TerminalApp/java/com/android/virtualization/terminal/TerminalView.java
index 77a48be..3f09e35 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/TerminalView.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/TerminalView.java
@@ -79,6 +79,73 @@
""";
public static final String ENABLE_CTRL_KEY = "(function(){window.ctrl=true;})();";
+ // TODO(b/375326606): consider contribution on
+ // upstream(https://github.com/xtermjs/xterm.js/issues/3727)
+ public static final String TOUCH_TO_MOUSE_HANDLER =
+ """
+(function() {
+let convertTouchToMouse = false;
+function touchHandler(event) {
+ const contextmenuByTouch =
+ event.type === 'contextmenu' && event.pointerType === 'touch';
+ // Only proceed for long touches (contextmenu) or when converting touch to
+ // mouse
+ if (!contextmenuByTouch && !convertTouchToMouse) {
+ return;
+ }
+
+ const touch = event.changedTouches ? event.changedTouches[0] : event;
+
+ let type;
+ switch (event.type) {
+ case 'contextmenu':
+ convertTouchToMouse = true;
+ type = 'mousedown';
+ break;
+ case 'touchmove':
+ type = 'mousemove';
+ break;
+ case 'touchend':
+ convertTouchToMouse = false;
+ type = 'mouseup';
+ break;
+ default:
+ convertTouchToMouse = false;
+ return;
+ }
+
+ const simulatedEvent = new MouseEvent(type, {
+ bubbles: true,
+ cancelable: true,
+ view: window,
+ detail: 1,
+ screenX: touch.screenX,
+ screenY: touch.screenY,
+ clientX: touch.clientX,
+ clientY: touch.clientY,
+ button: 0, // left click
+ });
+
+ touch.target.dispatchEvent(simulatedEvent);
+
+ // Prevent default behavior for touch events (except contextmenu)
+ if (event.type !== 'contextmenu') {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+}
+const eventOptions = {
+ capture: true,
+ passive: false
+};
+document.addEventListener('touchstart', touchHandler, eventOptions);
+document.addEventListener('touchmove', touchHandler, eventOptions);
+document.addEventListener('touchend', touchHandler, eventOptions);
+document.addEventListener('touchcancel', touchHandler, eventOptions);
+document.addEventListener('contextmenu', touchHandler, eventOptions);
+})();
+""";
+
private final AccessibilityManager mA11yManager;
public TerminalView(Context context, AttributeSet attrs) {
diff --git a/android/compos_verify/verify.rs b/android/compos_verify/verify.rs
index a3f18d5..b94ebbc 100644
--- a/android/compos_verify/verify.rs
+++ b/android/compos_verify/verify.rs
@@ -124,6 +124,7 @@
&idsig_manifest_ext_apk,
&VmParameters {
name: String::from("ComposVerify"),
+ os: String::from("microdroid"),
cpu_topology: VmCpuTopology::OneCpu, // This VM runs very little work at boot
debug_mode: args.debug,
..Default::default()
diff --git a/android/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl b/android/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
index dde75e1..3748899 100644
--- a/android/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
+++ b/android/composd/aidl/android/system/composd/IIsolatedCompilationService.aidl
@@ -48,5 +48,6 @@
* callback, unless the returned ICompilationTask is cancelled. The caller should maintain
* a reference to the ICompilationTask until compilation completes or is cancelled.
*/
- ICompilationTask startTestCompile(ApexSource apexSource, ICompilationTaskCallback callback);
+ ICompilationTask startTestCompile(
+ ApexSource apexSource, ICompilationTaskCallback callback, String os);
}
diff --git a/android/composd/src/instance_manager.rs b/android/composd/src/instance_manager.rs
index 9e94035..d1b0b99 100644
--- a/android/composd/src/instance_manager.rs
+++ b/android/composd/src/instance_manager.rs
@@ -46,11 +46,12 @@
self.start_instance(CURRENT_INSTANCE_DIR, vm_parameters)
}
- pub fn start_test_instance(&self, prefer_staged: bool) -> Result<CompOsInstance> {
+ pub fn start_test_instance(&self, prefer_staged: bool, os: &str) -> Result<CompOsInstance> {
let mut vm_parameters = new_vm_parameters()?;
vm_parameters.name = String::from("ComposdTest");
vm_parameters.debug_mode = true;
vm_parameters.prefer_staged = prefer_staged;
+ vm_parameters.os = os.to_owned();
self.start_instance(TEST_INSTANCE_DIR, vm_parameters)
}
@@ -83,7 +84,8 @@
// number of dex2oat threads.
let cpu_topology = VmCpuTopology::MatchHost;
let memory_mib = Some(compos_memory_mib()?);
- Ok(VmParameters { cpu_topology, memory_mib, ..Default::default() })
+ let os = "microdroid".to_owned();
+ Ok(VmParameters { cpu_topology, memory_mib, os, ..Default::default() })
}
fn compos_memory_mib() -> Result<i32> {
diff --git a/android/composd/src/service.rs b/android/composd/src/service.rs
index 49cfd3a..3cc40af 100644
--- a/android/composd/src/service.rs
+++ b/android/composd/src/service.rs
@@ -60,6 +60,7 @@
&self,
apex_source: ApexSource,
callback: &Strong<dyn ICompilationTaskCallback>,
+ os: &str,
) -> binder::Result<Strong<dyn ICompilationTask>> {
check_permissions()?;
let prefer_staged = match apex_source {
@@ -67,7 +68,7 @@
ApexSource::PreferStaged => true,
_ => unreachable!("Invalid ApexSource {:?}", apex_source),
};
- to_binder_result(self.do_start_test_compile(prefer_staged, callback))
+ to_binder_result(self.do_start_test_compile(prefer_staged, callback, os))
}
}
@@ -93,9 +94,12 @@
&self,
prefer_staged: bool,
callback: &Strong<dyn ICompilationTaskCallback>,
+ os: &str,
) -> Result<Strong<dyn ICompilationTask>> {
- let comp_os =
- self.instance_manager.start_test_instance(prefer_staged).context("Starting CompOS")?;
+ let comp_os = self
+ .instance_manager
+ .start_test_instance(prefer_staged, os)
+ .context("Starting CompOS")?;
let target_dir_name = TEST_ARTIFACTS_SUBDIR.to_owned();
let task = OdrefreshTask::start(
diff --git a/android/composd_cmd/composd_cmd.rs b/android/composd_cmd/composd_cmd.rs
index 6d096a1..6281bd0 100644
--- a/android/composd_cmd/composd_cmd.rs
+++ b/android/composd_cmd/composd_cmd.rs
@@ -46,6 +46,10 @@
/// If any APEX is staged, prefer the staged version.
#[clap(long)]
prefer_staged: bool,
+
+ /// OS for the VM.
+ #[clap(long, default_value = "microdroid")]
+ os: String,
},
}
@@ -56,7 +60,7 @@
match action {
Actions::StagedApexCompile {} => run_staged_apex_compile()?,
- Actions::TestCompile { prefer_staged } => run_test_compile(prefer_staged)?,
+ Actions::TestCompile { prefer_staged, os } => run_test_compile(prefer_staged, &os)?,
}
println!("All Ok!");
@@ -116,9 +120,9 @@
run_async_compilation(|service, callback| service.startStagedApexCompile(callback))
}
-fn run_test_compile(prefer_staged: bool) -> Result<()> {
+fn run_test_compile(prefer_staged: bool, os: &str) -> Result<()> {
let apex_source = if prefer_staged { ApexSource::PreferStaged } else { ApexSource::NoStaged };
- run_async_compilation(|service, callback| service.startTestCompile(apex_source, callback))
+ run_async_compilation(|service, callback| service.startTestCompile(apex_source, callback, os))
}
fn run_async_compilation<F>(start_compile_fn: F) -> Result<()>
diff --git a/libs/libcompos_common/compos_client.rs b/libs/libcompos_common/compos_client.rs
index 316eaa9..6872582 100644
--- a/libs/libcompos_common/compos_client.rs
+++ b/libs/libcompos_common/compos_client.rs
@@ -58,6 +58,8 @@
pub struct VmParameters {
/// The name of VM for identifying.
pub name: String,
+ /// The OS of VM.
+ pub os: String,
/// Whether the VM should be debuggable.
pub debug_mode: bool,
/// CPU topology of the VM. Defaults to 1 vCPU.
@@ -129,6 +131,7 @@
let config = VirtualMachineConfig::AppConfig(VirtualMachineAppConfig {
name: parameters.name.clone(),
+ osName: parameters.os.clone(),
apk: Some(apk_fd),
idsig: Some(idsig_fd),
instanceId: instance_id,