Retrofit vsoc_input_service to use vsock
This allows using vsoc_input_service under qemu without the vsoc/ivshmem
support that is missing in 4.19 gki.
The alternative is to use virtio-input, but in qemu this requires
forwarding a hardware device (by using root permissions) while in crosvm
the same functionality is available through a file descriptor.
Test: launch_cvd -vm_manager=qemu_cli, check adb and vnc
Bug: 143713267
Change-Id: Ice9767b28d9011fba6389435c029bed2e80ba7b8
diff --git a/shared/config/init.common.rc b/shared/config/init.common.rc
index 162da7c..1be009f 100644
--- a/shared/config/init.common.rc
+++ b/shared/config/init.common.rc
@@ -125,6 +125,15 @@
user root
disabled
+service vsoc_input_service /vendor/bin/vsoc_input_service -touch_port=${ro.boot.vsock_touch_port} -keyboard_port=${ro.boot.vsock_keyboard_port}
+ group root uhid
+ disabled
+
+on early-boot && property:ro.boot.vsock_touch_port=*
+ enable vsoc_input_service
+
+on early-boot && property:ro.boot.vsock_keyboard_port=*
+ enable vsoc_input_service
service wpa_supplicant /vendor/bin/hw/wpa_supplicant -g@android:wpa_wlan0
interface android.hardware.wifi.supplicant@1.0::ISupplicant default
diff --git a/shared/sepolicy/vendor/property_contexts b/shared/sepolicy/vendor/property_contexts
index 08c1150..383c3ec 100644
--- a/shared/sepolicy/vendor/property_contexts
+++ b/shared/sepolicy/vendor/property_contexts
@@ -9,7 +9,9 @@
ro.boot.hardware.hwcomposer u:object_r:cf_graphics_config_prop:s0 exact string
ro.boot.lcd_density u:object_r:cf_graphics_config_prop:s0 exact int
ro.boot.vsock_frames_port u:object_r:vsock_frames_port_prop:s0
+ro.boot.vsock_keyboard_port u:object_r:cuttlefish_vsock_keyboard_port:s0
ro.boot.vsock_logcat_port u:object_r:vsock_logcat_port_prop:s0
+ro.boot.vsock_touch_port u:object_r:cuttlefish_vsock_touch_port:s0
ro.cdma.home.operator.alpha u:object_r:vendor_init_radio_prop:s0
ro.cdma.home.operator.numeric u:object_r:vendor_init_radio_prop:s0
sys.cf.ser. u:object_r:sys_cf_ser_prop:s0
diff --git a/shared/sepolicy/vendor/vsoc_input_service.te b/shared/sepolicy/vendor/vsoc_input_service.te
index b45d61c..f8abddc 100644
--- a/shared/sepolicy/vendor/vsoc_input_service.te
+++ b/shared/sepolicy/vendor/vsoc_input_service.te
@@ -1,5 +1,7 @@
type vsoc_input_service, domain;
type vsoc_input_service_exec, exec_type, vendor_file_type, file_type;
+type cuttlefish_vsock_keyboard_port, property_type;
+type cuttlefish_vsock_touch_port, property_type;
init_daemon_domain(vsoc_input_service)
@@ -10,3 +12,9 @@
allow vsoc_input_service region_screen_device:chr_file rw_file_perms;
allow vsoc_input_service input_events_device:chr_file rw_file_perms;
+
+net_domain(vsoc_input_service)
+
+get_prop(vsoc_input_service, cuttlefish_config_server_port_prop)
+
+allow vsoc_input_service self:{ socket vsock_socket } create_socket_perms_no_ioctl;