Merge "Remove bufferhub@1.0 from the hal_implementation_test"
diff --git a/README.md b/README.md
index 55668c8..06db0c4 100644
--- a/README.md
+++ b/README.md
@@ -78,12 +78,3 @@
WebRTC on Cuttlefish
[documentation](https://source.android.com/setup/create/cuttlefish-ref-webrtc).
-## Launch Viewer (VNC)
-
-When launching with `--start_vnc_server=true` , You can use the
-[TightVNC JViewer](https://www.tightvnc.com/download.php). Once you have
-downloaded the *TightVNC Java Viewer JAR in a ZIP archive*, run it with
-
- `$ java -jar tightvnc-jviewer.jar -ScalingFactor=50 -Tunneling=no -host=localhost -port=6444`
-
-Click "Connect" and you should see a lock screen!
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 889dfbe..83229e3 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -21,6 +21,12 @@
"name": "vts_ibase_test"
},
{
+ "name": "OverlayDeviceTests"
+ },
+ {
+ "name": "CtsNativeVerifiedBootTestCases"
+ },
+ {
"name": "CtsScopedStorageDeviceOnlyTest"
},
{
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/Android.bp b/apex/com.google.aosp_cf_x86_64_phone.rros/Android.bp
new file mode 100644
index 0000000..53fc4bf
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/Android.bp
@@ -0,0 +1,27 @@
+apex_key {
+ name: "com.google.aosp_cf_x86_64_phone.rros.key",
+ public_key: "com.google.aosp_cf_x86_64_phone.rros.avbpubkey",
+ private_key: "com.google.aosp_cf_x86_64_phone.rros.pem",
+}
+
+android_app_certificate {
+ name: "com.google.aosp_cf_x86_64_phone.rros.certificate",
+ certificate: "com.google.aosp_cf_x86_64_phone.rros",
+}
+
+apex {
+ name: "com.google.aosp_cf_x86_64_phone.rros",
+ manifest: "apex_manifest.json",
+ key: "com.google.aosp_cf_x86_64_phone.rros.key",
+ certificate: ":com.google.aosp_cf_x86_64_phone.rros.certificate",
+ file_contexts: "file_contexts",
+ use_vndk_as_stable: true,
+ updatable: false,
+ // Install the apex in /vendor/apex
+ soc_specific: true,
+ rros: [
+ "cuttlefish_overlay_frameworks_base_core",
+ "cuttlefish_overlay_settings_provider",
+ "cuttlefish_phone_overlay_frameworks_base_core",
+ ],
+}
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/apex_manifest.json b/apex/com.google.aosp_cf_x86_64_phone.rros/apex_manifest.json
new file mode 100644
index 0000000..47cefb5
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/apex_manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.google.aosp_cf_x86_64_phone.rros",
+ "version": 1
+}
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.avbpubkey b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.avbpubkey
new file mode 100644
index 0000000..6e1d8f4
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.avbpubkey
Binary files differ
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.pem b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.pem
new file mode 100644
index 0000000..983b60a
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.pem
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJJwIBAAKCAgEAqC0nwqX1wlZ36lPHI7FEpkybWnCrElSARG1nhpAuDP1PCuUr
+CL/A/TJoMyi2QdblZJb28E2F1mHjfNYji+yINNC1v0RErBYfp+L+A9BLIFeTd+pU
+kXzXXsWjAgwKZ71GBaX1XpoWrUVcN2XoV6UeTONoXZmzrs5jJiKiTfUIcO0HwbIO
+3KXkHGCr7LO0wQAC7QDUsQL6a0MvdZ9O7abL3VbXIRMH4lliD43Q6qGQLFRt/VOQ
+ASYh7mWYfM0KpBXjAPU34crCfOGlN8M3T42bAdlYU5ju8sUGORq0ylr/Eb4gniiz
+L73mHfLgRPC4xyzanWr2ER89JfuoseubK+n9WnDRc3Pn45triBczHuWVNRUnZaon
+zpWlWsNnxUzGOW5esvtksmhgMMvqjH4TE19ndW7pPSfFEVk+AeWIL7pLV45Di/Wg
+738uL+pRCBzvG9Yu5W2WtAdcv9ysQEofiljDycQEXLWKKHu2Cb79czQ8SYyc5zve
+cOOJNZfpVBv7fD7nJEzzJz5Il76m6HybmHXcWBJVldgfQiuQIpXfOsLpD++ss4iT
+TjPSjOx3mC+Eor7JEltn+atPAeRWHABOB9oMdn63x8UiLRb7rUL7C+DBJNeYtaWT
+M9jOAZuIDdEc/4FWNOXauUlzGmu6MTkRScii3f0G3fJquK7bLlQDSZrrc4sCAwEA
+AQKCAgAFRKzbLyG8vcKx53/0gUgaQYoYUjE5uMXv3tGAaKHYrFK+j6FCe+dKxzp2
+Z88VzuqOtR/1NSh9J8HdlkO0zWsS5HrdDAFutp61PqoganUABV5MQl311MhWYrCR
+jtkAmPBJmwJNvVv6f5K89YdKv5Rsai9Jx1fWoQaAGlOlR4jFKNe2XKKUjOnRbcHU
+/2gpJ5vv2rfO973qgEdLUvtA/JmkTGUe1x7HG2+z9whVYUxH5zku12BKeOxVMH+P
+YUj1DO54iDYA774Z9WOclJP1/QSfETTwIXlSx5NDVK/XKvSUlLUm3zWFyFgeFg6q
+ejP/oUsT5VbiAG2E9BY7xJquzHywPJiYMyMtS/Sw0ditEMg3vZ1IFwWXQeN+AJxR
+3CIa1ZDG/KLx2Zk2wQfUo9ibpaxfPuYZC+Vknbf0RpSXE/gj484SBwSM8x2ml3YM
++DPOvm8Jdy+fOy0X6lH/ERLXe5zc4LEg6hiA+6MgOIaPnWr3ag71fmOOjb1w41kp
+lasQ0Q6bkKowgEjVoNHA4Ekz14hGuQebGl/YJCKQ/EOtvkZxTGMzbWw1hvO4n+g2
+O1QtI2EDrKmfCLTB7OeIh+Pq0Hkc7Tp1MI+7ciZEWFwVtcgTivrKU6N9WX9tONvQ
+gASEkpacwa3Dhb+YQWih6OOhed/K+7U3u6QSjUAziX12QHzFEQKCAQEA1q8GDp9u
+lRbKImlUDTSbnjiRm1VNV3m/Mr1FfMNnQ9iwJAgdECKe8Egmia8uiTokMsBvpLl/
+giFWDLfzzeqtnMTSAxAMhi1n6343U9EiTVkUJPXyolDyioFtuyxLF+8O4XOjIFAq
+8MtgDDulWDVhxGCuuYUSKmANbu6SXfccRwSiYgwqWLSIfGQOaxdN87xVsdeosjs9
+H2FqHZbbg4CFZJ4kItGsKb1C+b9rtiaombghMVE0FsvCgIZC8n8K5HXtFNJ9VnwX
+Ji7zlN/rlJFsKIUwc1fCl3kpmW8OPIJ7TV+lAm8mJM40SCErl2EoXhe8SZ8k/db+
+NF+kjzBMwl9cEwKCAQEAyIrSro6bSiq/YrU6g+xRaVacp70lqBFvaPj/sZb2nkoW
+ncLF6IFcNVefOu/dkbd9d9iBcser40LULn75o+b6gOZeiOByShrhC5ZI1f0P0y5d
+KhEN27c/PbpsbIuuLPYWV6dYCwL9Zn3yMJoiKATOd0LirN0uLgBNmFOMZMdWmc+5
+v0oZpHIHUkydtfr8O4hZAI9d//1ksREHLIJ6r7xjyLgLZE4rztJhUAMZNBw0TvHi
+3V1DO4GMPphtw082RUcOS+u5COgsZoxSGslxHfNz+DsiohtlqPs4/FtqlxhipYmo
+6naF3I40MrMrGZPnXqnzAJERAhGFsSFI9zOIwrkJqQKCAQAJxl5YPBok36zEdFdH
+YqXTRnAayn+DBCAYh1WqoJsLE8qxWU05dtoVxrM6gad0yBjt1qU+stODcVEhsx5+
+ubi98pg9W3W2hkq9Bjours8JBo1MQYaSrWzdsZb1dsbUiCX9Te6Xgg7yd9AfvneA
+1K1m66AJAm4ZT9ZMvsAbVy0KbsOWA0fKUi4Eu+mMJrt95Y1hU5hyxQ+7ZgwW3M+R
+5UAtnKW4kCNuoxdxl62n1YrHtQKN5Eyi3RQ2Febmc7JjRJtO32alkXDcZDbjCG8J
+jLWIAsh59/z8OKAURGI5jxdeJoS036q08k6fGiOJ+PqFjj8cewqMJEXezJwJiQF1
+uDHRAoIBAFOrT9FSYEnmYek98Yb+/sxzPXLigKaJd7EVSiD++i/6e0sg609hQWZk
+A2QklY3pP2jUJNYNppJv3HT1txQCF3vWIZT8B9MROdmKvyLArWyPiIE3kk+cOb94
+WypCcM4Dcjjp8drOSYkMfRJ4DE4kCzxI5Kf4s/6vU7B9EzMs093ig/3iXaZ1iMZ2
+fsphSAFSlsecCTz3rJ4Pm62fVq6hbARffSlBUBe/QKiQUmCib9SMKPnwok9ecnPf
+RtRY5SysQ7O7Sn0D2RqD6vGQICi93SGxEncN9TE2d4UaYvNdUjL8p0QDZUAq+G46
+wH2wbrTZNTCEVdNGGkBXwciZcLLFXtkCggEANRIwJqIEGIDEqtEG26ZcEH8MNbCV
+a/jLqdOGSUx8m03kZF49VFO3+r4mrR7zsqG6JcpUMKxAgoYJtDcFR7Mt7mYTjoVM
+fggtViQkO2Mf91V0djgGgSrDOh1qutSXU1a4s0Hi8RGJ1RW/Hre7gzL8xvFEHQcw
++7QINhqISsyA+pNYemP0f0AQZVPlgFCnFn2IN0NlFUKCa5f4XGjsaYvy2KOFywf0
+DMkPZsHsHGft6mKo4qY4SrgFhLO9F1z8kJP3qfBOlua+g61af8JEGxngSln9wsvp
+deQidpn89ySSI7E5O/Lw7qU2rc/Dl/b7/V0nWKJiQwnsiJqZFh6u4bqMlw==
+-----END RSA PRIVATE KEY-----
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.pk8 b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.pk8
new file mode 100644
index 0000000..e5b0715
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.pk8
Binary files differ
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.x509.pem b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.x509.pem
new file mode 100644
index 0000000..0eec724
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/com.google.aosp_cf_x86_64_phone.rros.x509.pem
@@ -0,0 +1,34 @@
+-----BEGIN CERTIFICATE-----
+MIIF7TCCA9UCFD5v26bgR11NcZiW2qEfGMY8OdDbMA0GCSqGSIb3DQEBCwUAMIGx
+MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91
+bnRhaW4gVmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEi
+MCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTEtMCsGA1UEAwwkY29t
+Lmdvb2dsZS5hb3NwX2NmX3g4Nl82NF9waG9uZS5ycm9zMCAXDTIxMDkxNjIyMjEw
+M1oYDzQ3NTkwODEzMjIyMTAzWjCBsTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh
+bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB0FuZHJv
+aWQxEDAOBgNVBAsMB0FuZHJvaWQxIjAgBgkqhkiG9w0BCQEWE2FuZHJvaWRAYW5k
+cm9pZC5jb20xLTArBgNVBAMMJGNvbS5nb29nbGUuYW9zcF9jZl94ODZfNjRfcGhv
+bmUucnJvczCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMCYk9akxyUI
+8usUQ1GxPZbEnHWaZx2jqBc7IAObo6+5Ct7UXdhUC0GfHfJvb5ushDuxXAmN7Itk
+ygz4+YXijwFyFhNJOIOmRcw2hf6sjc4WqjB9uwREgxz42eJQ/GG8Bq6vtkfOtKnh
+hcd+natyeeIynYFwRK6HtZJrYXwtluqPfTrItfhbTx0/xFcZARCuJLieJj1rovEc
+HUgrj8PMZlU2S+vXPU5HninJu11i8aCHePASJAgLQ9s7dUo+3VxrHGG7i6ENPDAm
+LXS9reFoMuBhJm88gPH5mHGXbfmdD9rWCBxPYS/YmC18zXInTzo8sff6Gao3OrkO
+zTLh74nghBd5ViJB8xk8L+Sz2Zj3yAc3oIYBTYP5IbRCCMW84IGHb3a1mfdfk8Cd
+THUB/+nOSCvRlXFwJeTB7mYO2vLpqmu5rj3CKU5EwzlUTsdy7wFYsqAQCrR55WVc
+SsanWHrDKN+16t15H/vL0AMw6Je6JyCu9B6D+tRTs6UDgPpMzxN7LVivgTwUQwJg
++Vab6xwhWGBB28IvBtwSSmUZcXAadL1/k6LpY4EVH/eXQp72uzXJhe/uK8zZerdv
+WRS2EEJEV9BjagodestZLDLBR5KOEt2zD1t8UaCPBawleZuTXOEChIYs+yeSo//m
+Qu6CUMDyW2kedZKrzbJ7mgKwFTDPlBgDAgMBAAEwDQYJKoZIhvcNAQELBQADggIB
+AA7u1TkOyzKx0gEIfTxUEBKvVdrkUL4EaQxN/Sgh+dMsLpDcp4kspkrd6LXhC23X
+h4qm1/+z6hw6IXSQ1nnfJjOSN1ItJxmHOE/gTJRWecwoSxS9dwkpmS2VHwh4UAOb
+H1M5sPtjlEU7ecBhCFD0gKis82VJJZ/kTA3Sc2yT+hcpgN7ZhJVLiiMplFLj5LlE
+YWOZY3SgW9UjxJ310PRI6EyNmiWnrLrQcvmXIYG5Hc35ElNril5QWHh0G5CeBrcG
+2IIA99/z25Pe3AOa6rfxED0DZvoNCDLsfAqQAspvu8Z/fUDEjMvqQonsxgdEn6dJ
+hetXSi6EL+6Czuyxd9+UpOlulEqhRprCWq5e+eRx42ynqURCEjIyIiXizM72tM97
+9BtXZyXDv5yn4LqKpTDfgwZ9tSneDyYF4RIv5wOTwhoqzVdTCFpv/bF+HTNI7fCE
+Fvifafm7KIlhqew8Ya3GkeN1Tyq1aZ6Lj5VoFqEQF0n/M1RCXrJWBC+BqY8wCNdz
+Rbm9TitIDBvP6GSuHiqs6xcF6tCC5c5whi6ltWGTJMSHdCuZSs8ppzkrmde2Smpd
+HCjrquPwTZCpxhVZkUDes7I6uChoTt26GxoeIClQXuK46sdGe8YUK/Rw59hEw4Gs
+HxCg3qHmvdbZD6XyimnMKcXa7Rbn4fLgUue0FJD8cOaM
+-----END CERTIFICATE-----
diff --git a/apex/com.google.aosp_cf_x86_64_phone.rros/file_contexts b/apex/com.google.aosp_cf_x86_64_phone.rros/file_contexts
new file mode 100644
index 0000000..cb7fd8d
--- /dev/null
+++ b/apex/com.google.aosp_cf_x86_64_phone.rros/file_contexts
@@ -0,0 +1,2 @@
+(/.*)? u:object_r:vendor_file:s0
+/overlay(/.*)? u:object_r:vendor_overlay_file:s0
diff --git a/build/Android.bp b/build/Android.bp
index 1160a47..282346b 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -37,6 +37,7 @@
"allocd",
"allocd_client",
"assemble_cvd",
+ "avbtool",
"bt_connector",
"common_crosvm",
"config_server",
@@ -84,7 +85,6 @@
"tombstone_receiver",
"toybox",
"unpack_bootimg",
- "vnc_server",
"webRTC",
"webrtc_operator",
"wmediumd",
diff --git a/common/libs/fs/shared_buf.cc b/common/libs/fs/shared_buf.cc
index d6aed57..f4b24dd 100644
--- a/common/libs/fs/shared_buf.cc
+++ b/common/libs/fs/shared_buf.cc
@@ -33,14 +33,17 @@
ssize_t WriteAll(SharedFD fd, const char* buf, size_t size) {
size_t total_written = 0;
ssize_t written = 0;
- while (total_written < size) {
+ do {
written = fd->Write((void*)&(buf[total_written]), size - total_written);
- if (written < 0) {
- errno = fd->GetErrno();
- return written;
+ if (written <= 0) {
+ if (written < 0) {
+ errno = fd->GetErrno();
+ return written;
+ }
+ return total_written;
}
total_written += written;
- }
+ } while (total_written < size);
return total_written;
}
diff --git a/common/libs/fs/shared_buf.h b/common/libs/fs/shared_buf.h
index b0db79a..f1a02c2 100644
--- a/common/libs/fs/shared_buf.h
+++ b/common/libs/fs/shared_buf.h
@@ -99,6 +99,12 @@
*
* If a write error is encountered, returns -1. Some data may have already been
* written to fd at that point.
+ *
+ * If the size of buf is 0, WriteAll returns 0 with no error set unless
+ * the fd is a regular file. If fd is a regular file, write(fd, buf, 0) is
+ * effectively called. It may detect errors; if detected, errno is set and
+ * -1 is returned. If not detected, 0 is returned with errno unchanged.
+ *
*/
ssize_t WriteAll(SharedFD fd, const std::string& buf);
@@ -109,6 +115,12 @@
*
* If a write error is encountered, returns -1. Some data may have already been
* written to fd at that point.
+ *
+ * If the size of buf is 0, WriteAll returns 0 with no error set unless
+ * the fd is a regular file. If fd is a regular file, write(fd, buf, 0) is
+ * effectively called. It may detect errors; if detected, errno is set and
+ * -1 is returned. If not detected, 0 is returned with errno unchanged.
+ *
*/
ssize_t WriteAll(SharedFD fd, const std::vector<char>& buf);
@@ -119,6 +131,12 @@
*
* If a write error is encountered, returns -1. Some data may have already been
* written to fd at that point.
+ *
+ * If size is 0, WriteAll returns 0 with no error set unless
+ * the fd is a regular file. If fd is a regular file, write(fd, buf, 0) is
+ * effectively called. It may detect errors; if detected, errno is set and
+ * -1 is returned. If not detected, 0 is returned with errno unchanged.
+ *
*/
ssize_t WriteAll(SharedFD fd, const char* buf, size_t size);
@@ -129,6 +147,12 @@
*
* If a write error is encountered, returns -1. Some data may have already been
* written to fd at that point.
+ *
+ * If ever sizeof(T) is 0, WriteAll returns 0 with no error set unless
+ * the fd is a regular file. If fd is a regular file, write(fd, buf, 0) is
+ * effectively called. It may detect errors; if detected, errno is set and
+ * -1 is returned. If not detected, 0 is returned with errno unchanged.
+ *
*/
template<typename T>
ssize_t WriteAllBinary(SharedFD fd, const T* binary_data) {
diff --git a/common/libs/fs/shared_fd.cpp b/common/libs/fs/shared_fd.cpp
index 41333bc..8723d8f 100644
--- a/common/libs/fs/shared_fd.cpp
+++ b/common/libs/fs/shared_fd.cpp
@@ -83,6 +83,14 @@
#endif
}
+bool IsRegularFile(const int fd) {
+ struct stat info;
+ if (fstat(fd, &info) < 0) {
+ return false;
+ }
+ return S_ISREG(info.st_mode);
+}
+
} // namespace
bool FileInstance::CopyFrom(FileInstance& in, size_t length) {
@@ -714,6 +722,9 @@
}
ssize_t FileInstance::Write(const void* buf, size_t count) {
+ if (count == 0 && !IsRegular()) {
+ return 0;
+ }
errno = 0;
ssize_t rval = TEMP_FAILURE_RETRY(write(fd_, buf, count));
errno_ = errno;
@@ -734,7 +745,8 @@
return rval;
}
-FileInstance::FileInstance(int fd, int in_errno) : fd_(fd), errno_(in_errno) {
+FileInstance::FileInstance(int fd, int in_errno)
+ : fd_(fd), errno_(in_errno), is_regular_file_(IsRegularFile(fd_)) {
// Ensure every file descriptor managed by a FileInstance has the CLOEXEC
// flag
TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, FD_CLOEXEC));
diff --git a/common/libs/fs/shared_fd.h b/common/libs/fs/shared_fd.h
index 3ccfc2e..da9d2fd 100644
--- a/common/libs/fs/shared_fd.h
+++ b/common/libs/fs/shared_fd.h
@@ -262,6 +262,9 @@
// in probably isn't modified, but the API spec doesn't have const.
bool IsSet(fd_set* in) const;
+ // whether this is a regular file or not
+ bool IsRegular() const { return is_regular_file_; }
+
/**
* Adds a hard link to a file descriptor, based on the current working
* directory of the process or to some absolute path.
@@ -300,6 +303,14 @@
std::string StrError() const;
ScopedMMap MMap(void* addr, size_t length, int prot, int flags, off_t offset);
ssize_t Truncate(off_t length);
+ /*
+ * If the file is a regular file and the count is 0, Write() may detect
+ * error(s) by calling write(fd, buf, 0) declared in <unistd.h>. If detected,
+ * it will return -1. If not, 0 will be returned. For non-regular files such
+ * as socket or pipe, write(fd, buf, 0) is not specified. Write(), however,
+ * will do nothing and just return 0.
+ *
+ */
ssize_t Write(const void* buf, size_t count);
int EventfdWrite(eventfd_t value);
bool IsATTY();
@@ -311,6 +322,7 @@
int fd_;
int errno_;
std::string identity_;
+ bool is_regular_file_;
};
/* Methods that need both a fully defined SharedFD and a fully defined
diff --git a/common/libs/security/keymaster_channel.cpp b/common/libs/security/keymaster_channel.cpp
index 7b3ab86..cfc427b 100644
--- a/common/libs/security/keymaster_channel.cpp
+++ b/common/libs/security/keymaster_channel.cpp
@@ -25,7 +25,7 @@
ManagedKeymasterMessage CreateKeymasterMessage(
AndroidKeymasterCommand command, bool is_response, size_t payload_size) {
- auto memory = new uint8_t[payload_size + sizeof(keymaster_message)];
+ auto memory = std::malloc(payload_size + sizeof(keymaster_message));
auto message = reinterpret_cast<keymaster_message*>(memory);
message->cmd = command;
message->is_response = is_response;
@@ -37,7 +37,7 @@
{
keymaster::Eraser(ptr, sizeof(keymaster_message) + ptr->payload_size);
}
- delete reinterpret_cast<uint8_t*>(ptr);
+ std::free(ptr);
}
KeymasterChannel::KeymasterChannel(SharedFD input, SharedFD output)
diff --git a/common/libs/utils/files.cpp b/common/libs/utils/files.cpp
index 65eb7cd..15e7ebe 100644
--- a/common/libs/utils/files.cpp
+++ b/common/libs/utils/files.cpp
@@ -18,16 +18,17 @@
#include <android-base/logging.h>
+#include <dirent.h>
+#include <ftw.h>
+#include <libgen.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <array>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fstream>
-#include <libgen.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
#include <vector>
#include "common/libs/fs/shared_fd.h"
@@ -88,6 +89,40 @@
return true;
}
+bool RecursivelyRemoveDirectory(const std::string& path) {
+ // Copied from libbase TemporaryDir destructor.
+ auto callback = [](const char* child, const struct stat*, int file_type,
+ struct FTW*) -> int {
+ switch (file_type) {
+ case FTW_D:
+ case FTW_DP:
+ case FTW_DNR:
+ if (rmdir(child) == -1) {
+ PLOG(ERROR) << "rmdir " << child;
+ }
+ break;
+ case FTW_NS:
+ default:
+ if (rmdir(child) != -1) {
+ break;
+ }
+ // FALLTHRU (for gcc, lint, pcc, etc; and following for clang)
+ FALLTHROUGH_INTENDED;
+ case FTW_F:
+ case FTW_SL:
+ case FTW_SLN:
+ if (unlink(child) == -1) {
+ PLOG(ERROR) << "unlink " << child;
+ }
+ break;
+ }
+ return 0;
+ };
+
+ return nftw(path.c_str(), callback, 128, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) ==
+ 0;
+}
+
std::string AbsolutePath(const std::string& path) {
if (path.empty()) {
return {};
@@ -143,11 +178,10 @@
}
bool RemoveFile(const std::string& file) {
- LOG(DEBUG) << "Removing " << file;
+ LOG(DEBUG) << "Removing file " << file;
return remove(file.c_str()) == 0;
}
-
std::string ReadFile(const std::string& file) {
std::string contents;
std::ifstream in(file, std::ios::in | std::ios::binary);
diff --git a/common/libs/utils/files.h b/common/libs/utils/files.h
index 5d28d3d..a7ac455 100644
--- a/common/libs/utils/files.h
+++ b/common/libs/utils/files.h
@@ -26,6 +26,7 @@
std::vector<std::string> DirectoryContents(const std::string& path);
bool DirectoryExists(const std::string& path);
bool IsDirectoryEmpty(const std::string& path);
+bool RecursivelyRemoveDirectory(const std::string& path);
off_t FileSize(const std::string& path);
bool RemoveFile(const std::string& file);
bool RenameFile(const std::string& old_name, const std::string& new_name);
diff --git a/guest/commands/bt_vhci_forwarder/bt_vhci_forwarder.rc b/guest/commands/bt_vhci_forwarder/bt_vhci_forwarder.rc
new file mode 100644
index 0000000..8b7fb36
--- /dev/null
+++ b/guest/commands/bt_vhci_forwarder/bt_vhci_forwarder.rc
@@ -0,0 +1,7 @@
+on post-fs
+ start bt_vhci_forwarder
+
+service bt_vhci_forwarder /vendor/bin/bt_vhci_forwarder -virtio_console_dev=${vendor.ser.bt-uart}
+ user bluetooth
+ group bluetooth
+
diff --git a/guest/libs/wpa_supplicant_8_lib/Android.bp b/guest/libs/wpa_supplicant_8_lib/Android.bp
index f41509f..d09457e 100644
--- a/guest/libs/wpa_supplicant_8_lib/Android.bp
+++ b/guest/libs/wpa_supplicant_8_lib/Android.bp
@@ -1,3 +1,7 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
cc_library_static {
name: "lib_driver_cmd_simulated_cf_bp",
srcs: ["driver_cmd_nl80211.c"],
diff --git a/host/commands/assemble_cvd/assemble_cvd.cc b/host/commands/assemble_cvd/assemble_cvd.cc
index b4c06c7..41e0231 100644
--- a/host/commands/assemble_cvd/assemble_cvd.cc
+++ b/host/commands/assemble_cvd/assemble_cvd.cc
@@ -165,7 +165,8 @@
ss.str("");
}
}
- CHECK(CleanPriorFiles(preserving, FLAGS_assembly_dir, FLAGS_instance_dir))
+ CHECK(
+ CleanPriorFiles(preserving, FLAGS_assembly_dir, config.instance_dirs()))
<< "Failed to clean prior files";
// Create assembly directory if it doesn't exist.
@@ -189,8 +190,13 @@
}
std::string first_instance = FLAGS_instance_dir + "." + std::to_string(GetInstance());
+ if (FileExists(FLAGS_instance_dir)) {
+ CHECK(RemoveFile(FLAGS_instance_dir))
+ << "Failed to remove instance_dir symlink " << FLAGS_instance_dir;
+ }
CHECK_EQ(symlink(first_instance.c_str(), FLAGS_instance_dir.c_str()), 0)
- << "Could not symlink \"" << first_instance << "\" to \"" << FLAGS_instance_dir << "\"";
+ << "Could not symlink \"" << first_instance << "\" to \""
+ << FLAGS_instance_dir << "\"";
// Do this early so that the config object is ready for anything that needs it
auto config = CuttlefishConfig::Get();
diff --git a/host/commands/assemble_cvd/boot_config.cc b/host/commands/assemble_cvd/boot_config.cc
index 33d24f4..81cc038 100644
--- a/host/commands/assemble_cvd/boot_config.cc
+++ b/host/commands/assemble_cvd/boot_config.cc
@@ -59,7 +59,7 @@
}
// Note that the 0 index points to the GPT table.
- env << "bootcmd=boot_android virtio 0#misc" << '\0';
+ env << "bootcmd=verified_boot_android virtio 0#misc" << '\0';
if (FLAGS_vm_manager == CrosvmManager::name() &&
config.target_arch() == Arch::Arm64) {
env << "fdtaddr=0x80000000" << '\0';
diff --git a/host/commands/assemble_cvd/boot_image_utils.cc b/host/commands/assemble_cvd/boot_image_utils.cc
index 1483d9e..5e1cbd5 100644
--- a/host/commands/assemble_cvd/boot_image_utils.cc
+++ b/host/commands/assemble_cvd/boot_image_utils.cc
@@ -222,11 +222,20 @@
return false;
}
- auto fd = SharedFD::Open(tmp_boot_image_path, O_RDWR);
- auto original_size = FileSize(boot_image_path);
- CHECK(fd->Truncate(original_size) == 0)
- << "`truncate --size=" << original_size << " " << tmp_boot_image_path << "` "
- << "failed: " << fd->StrError();
+ auto avbtool_path = HostBinaryPath("avbtool");
+ Command avb_cmd(avbtool_path);
+ avb_cmd.AddParameter("add_hash_footer");
+ avb_cmd.AddParameter("--image");
+ avb_cmd.AddParameter(tmp_boot_image_path);
+ avb_cmd.AddParameter("--partition_size");
+ avb_cmd.AddParameter(FileSize(boot_image_path));
+ avb_cmd.AddParameter("--partition_name");
+ avb_cmd.AddParameter("boot");
+ success = avb_cmd.Start().Wait();
+ if (success != 0) {
+ LOG(ERROR) << "Unable to run avbtool. Exited with status " << success;
+ return false;
+ }
return DeleteTmpFileIfNotChanged(tmp_boot_image_path, new_boot_image_path);
}
@@ -296,11 +305,20 @@
return false;
}
- auto fd = SharedFD::Open(tmp_vendor_boot_image_path, O_RDWR);
- auto original_size = FileSize(vendor_boot_image_path);
- CHECK(fd->Truncate(original_size) == 0)
- << "`truncate --size=" << original_size << " " << tmp_vendor_boot_image_path << "` "
- << "failed: " << fd->StrError();
+ auto avbtool_path = HostBinaryPath("avbtool");
+ Command avb_cmd(avbtool_path);
+ avb_cmd.AddParameter("add_hash_footer");
+ avb_cmd.AddParameter("--image");
+ avb_cmd.AddParameter(tmp_vendor_boot_image_path);
+ avb_cmd.AddParameter("--partition_size");
+ avb_cmd.AddParameter(FileSize(vendor_boot_image_path));
+ avb_cmd.AddParameter("--partition_name");
+ avb_cmd.AddParameter("vendor_boot");
+ success = avb_cmd.Start().Wait();
+ if (success != 0) {
+ LOG(ERROR) << "Unable to run avbtool. Exited with status " << success;
+ return false;
+ }
return DeleteTmpFileIfNotChanged(tmp_vendor_boot_image_path, new_vendor_boot_image_path);
}
diff --git a/host/commands/assemble_cvd/clean.cc b/host/commands/assemble_cvd/clean.cc
index 6197a8f..853e11f 100644
--- a/host/commands/assemble_cvd/clean.cc
+++ b/host/commands/assemble_cvd/clean.cc
@@ -113,10 +113,9 @@
} // namespace
-bool CleanPriorFiles(
- const std::set<std::string>& preserving,
- const std::string& assembly_dir,
- const std::string& instance_dir) {
+bool CleanPriorFiles(const std::set<std::string>& preserving,
+ const std::string& assembly_dir,
+ const std::vector<std::string>& instance_dirs) {
std::vector<std::string> paths = {
// Everything in the assembly directory
assembly_dir,
@@ -125,19 +124,7 @@
// The global link to the config file
GetGlobalConfigFileLink(),
};
-
- std::string runtime_dir_parent = cpp_dirname(AbsolutePath(instance_dir));
- std::string runtime_dirs_basename = cpp_basename(AbsolutePath(instance_dir));
-
- std::regex instance_dir_regex("^.+\\.[1-9]\\d*$");
- for (const auto& path : DirectoryContents(runtime_dir_parent)) {
- std::string absl_path = runtime_dir_parent + "/" + path;
- if((path.rfind(runtime_dirs_basename, 0) == 0) && std::regex_match(path, instance_dir_regex) &&
- DirectoryExists(absl_path)) {
- paths.push_back(absl_path);
- }
- }
- paths.push_back(instance_dir);
+ paths.insert(paths.end(), instance_dirs.begin(), instance_dirs.end());
return CleanPriorFiles(paths, preserving);
}
diff --git a/host/commands/assemble_cvd/clean.h b/host/commands/assemble_cvd/clean.h
index 1f33685..febd5c1 100644
--- a/host/commands/assemble_cvd/clean.h
+++ b/host/commands/assemble_cvd/clean.h
@@ -20,10 +20,9 @@
namespace cuttlefish {
-bool CleanPriorFiles(
- const std::set<std::string>& preserving,
- const std::string& assembly_dir,
- const std::string& instance_dir);
+bool CleanPriorFiles(const std::set<std::string>& preserving,
+ const std::string& assembly_dir,
+ const std::vector<std::string>& instance_dirs);
bool EnsureDirectoryExists(const std::string& directory_path);
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index d3f2f19..59420eb 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -102,10 +102,6 @@
DEFINE_bool(deprecated_boot_completed, false, "Log boot completed message to"
" host kernel. This is only used during transition of our clients."
" Will be deprecated soon.");
-DEFINE_bool(start_vnc_server, false, "Whether to start the vnc server process. "
- "The VNC server runs at port 6443 + i for "
- "the vsoc-i user or CUTTLEFISH_INSTANCE=i, "
- "starting from 1.");
DEFINE_bool(use_allocd, false,
"Acquire static resources from the resource allocator daemon.");
@@ -227,8 +223,6 @@
"Run cuttlefish in background, the launcher exits on boot "
"completed/failed");
-DEFINE_string(device_title, "", "Human readable name for the instance, "
- "used by the vnc_server for its server title");
DEFINE_string(setupwizard_mode, "DISABLED",
"One of DISABLED,OPTIONAL,REQUIRED");
@@ -339,11 +333,6 @@
return port_range;
}
-int NumStreamers() {
- auto start_flags = {FLAGS_start_vnc_server, FLAGS_start_webrtc};
- return std::count(start_flags.begin(), start_flags.end(), true);
-}
-
std::string StrForInstance(const std::string& prefix, int num) {
std::ostringstream stream;
stream << prefix << std::setfill('0') << std::setw(2) << num;
@@ -462,9 +451,6 @@
CuttlefishConfig InitializeCuttlefishConfiguration(
const std::string& instance_dir, int modem_simulator_count,
KernelConfig kernel_config, fruit::Injector<>& injector) {
- // At most one streamer can be started.
- CHECK(NumStreamers() <= 1);
-
CuttlefishConfig tmp_config_obj;
for (const auto& fragment : injector.getMultibindings<ConfigFragment>()) {
@@ -613,8 +599,6 @@
tmp_config_obj.set_crosvm_binary(FLAGS_crosvm_binary);
tmp_config_obj.set_tpm_device(FLAGS_tpm_device);
- tmp_config_obj.set_enable_vnc_server(FLAGS_start_vnc_server);
-
tmp_config_obj.set_seccomp_policy_dir(FLAGS_seccomp_policy_dir);
tmp_config_obj.set_enable_webrtc(FLAGS_start_webrtc);
@@ -736,7 +720,8 @@
instance.set_uuid(FLAGS_uuid);
instance.set_modem_simulator_host_id(1000 + num); // Must be 4 digits
- instance.set_vnc_server_port(6444 + num - 1);
+ // the deprecated vnc was 6444 + num - 1, and qemu_vnc was vnc - 5900
+ instance.set_qemu_vnc_server_port(544 + num - 1);
instance.set_adb_host_port(6520 + num - 1);
instance.set_adb_ip_and_port("0.0.0.0:" + std::to_string(6520 + num - 1));
instance.set_confui_host_vsock_port(7700 + num - 1);
@@ -768,7 +753,6 @@
FLAGS_bluetooth_default_commands_file);
instance.set_camera_server_port(FLAGS_camera_server_port);
- instance.set_device_title(FLAGS_device_title);
if (FLAGS_protected_vm) {
instance.set_virtual_disk_paths(
@@ -848,12 +832,10 @@
tmp_config_obj.set_enable_sandbox(FLAGS_enable_sandbox);
- // Audio is not available for VNC server
+ // Audio is not available for Arm64
SetCommandLineOptionWithMode(
"enable_audio",
- (FLAGS_start_vnc_server || (cuttlefish::HostArch() == cuttlefish::Arch::Arm64))
- ? "false"
- : "true",
+ (cuttlefish::HostArch() == cuttlefish::Arch::Arm64) ? "false" : "true",
SET_FLAGS_DEFAULT);
tmp_config_obj.set_enable_audio(FLAGS_enable_audio);
@@ -862,7 +844,7 @@
void SetDefaultFlagsForQemu(Arch target_arch) {
// for now, we don't set non-default options for QEMU
- if (FLAGS_gpu_mode == kGpuModeGuestSwiftshader && NumStreamers() == 0) {
+ if (FLAGS_gpu_mode == kGpuModeGuestSwiftshader && !FLAGS_start_webrtc) {
// This makes WebRTC the default streamer unless the user requests
// another via a --star_<streamer> flag, while at the same time it's
// possible to run without any streamer by setting --start_webrtc=false.
@@ -883,7 +865,7 @@
}
void SetDefaultFlagsForCrosvm() {
- if (NumStreamers() == 0) {
+ if (!FLAGS_start_webrtc) {
// This makes WebRTC the default streamer unless the user requests
// another via a --star_<streamer> flag, while at the same time it's
// possible to run without any streamer by setting --start_webrtc=false.
diff --git a/host/commands/cvd/Android.bp b/host/commands/cvd/Android.bp
index a4016b2..b3590d8 100644
--- a/host/commands/cvd/Android.bp
+++ b/host/commands/cvd/Android.bp
@@ -37,11 +37,5 @@
"cvd_internal_status",
"cvd_internal_stop",
],
- symlinks: [
- "cvd_host_bugreport",
- "cvd_status",
- "launch_cvd",
- "stop_cvd",
- ],
defaults: ["cuttlefish_host"],
}
diff --git a/host/commands/fetcher/build_api.cc b/host/commands/fetcher/build_api.cc
index 093ece3..17459fb 100644
--- a/host/commands/fetcher/build_api.cc
+++ b/host/commands/fetcher/build_api.cc
@@ -209,13 +209,15 @@
auto curl_response = curl.DownloadToJson(download_url_endpoint, Headers());
const auto& json = curl_response.data;
if (!(curl_response.HttpSuccess() || curl_response.HttpRedirect())) {
- LOG(FATAL) << "Error fetching the url of \"" << artifact << "\" for \""
+ LOG(ERROR) << "Error fetching the url of \"" << artifact << "\" for \""
<< build << "\". The server response was \"" << json
<< "\", and code was " << curl_response.http_code;
+ return false;
}
- CHECK(!json.isMember("error"))
- << "Response had \"error\" but had http success status. Received \""
- << json << "\"";
+ if (json.isMember("error")) {
+ LOG(ERROR) << "Response had \"error\" but had http success status. "
+ << "Received \"" << json << "\"";
+ }
if (!json.isMember("signedUrl")) {
LOG(ERROR) << "URL endpoint did not have json path: " << json;
return false;
diff --git a/host/commands/host_bugreport/Android.bp b/host/commands/host_bugreport/Android.bp
index 573cca8..76f184b 100644
--- a/host/commands/host_bugreport/Android.bp
+++ b/host/commands/host_bugreport/Android.bp
@@ -19,6 +19,7 @@
cc_binary {
name: "cvd_internal_host_bugreport",
+ symlinks: ["cvd_host_bugreport"],
srcs: [
"main.cc",
],
diff --git a/host/commands/run_cvd/launch_streamer.cpp b/host/commands/run_cvd/launch_streamer.cpp
index 1dd3bfc..1703fab 100644
--- a/host/commands/run_cvd/launch_streamer.cpp
+++ b/host/commands/run_cvd/launch_streamer.cpp
@@ -81,8 +81,8 @@
return commands;
}
-// Creates the frame and input sockets and add the relevant arguments to the vnc
-// server and webrtc commands
+// Creates the frame and input sockets and add the relevant arguments to
+// webrtc commands
class StreamerSockets : public virtual Feature {
public:
INJECT(StreamerSockets(const CuttlefishConfig& config,
@@ -170,51 +170,6 @@
SharedFD audio_server_;
};
-class VncServer : public virtual CommandSource, public DiagnosticInformation {
- public:
- INJECT(VncServer(const CuttlefishConfig& config,
- const CuttlefishConfig::InstanceSpecific& instance,
- StreamerSockets& sockets))
- : config_(config), instance_(instance), sockets_(sockets) {}
- // DiagnosticInformation
- std::vector<std::string> Diagnostics() const override {
- if (!Enabled()) {
- return {};
- }
- std::ostringstream out;
- out << "VNC server started on port "
- << config_.ForDefaultInstance().vnc_server_port();
- return {out.str()};
- }
-
- // CommandSource
- std::vector<Command> Commands() override {
- Command vnc_server(VncServerBinary());
- vnc_server.AddParameter("-port=", instance_.vnc_server_port());
- sockets_.AppendCommandArguments(vnc_server);
-
- std::vector<Command> commands;
- commands.emplace_back(std::move(vnc_server));
- return commands;
- }
-
- // Feature
- std::string Name() const override { return "VncServer"; }
- bool Enabled() const override {
- return sockets_.Enabled() && config_.enable_vnc_server();
- }
-
- private:
- std::unordered_set<Feature*> Dependencies() const override {
- return {static_cast<Feature*>(&sockets_)};
- }
- bool Setup() override { return true; }
-
- const CuttlefishConfig& config_;
- const CuttlefishConfig::InstanceSpecific& instance_;
- StreamerSockets& sockets_;
-};
-
class WebRtcServer : public virtual CommandSource,
public DiagnosticInformation {
public:
@@ -359,12 +314,9 @@
launchStreamerComponent() {
return fruit::createComponent()
.addMultibinding<CommandSource, WebRtcServer>()
- .addMultibinding<CommandSource, VncServer>()
.addMultibinding<DiagnosticInformation, WebRtcServer>()
- .addMultibinding<DiagnosticInformation, VncServer>()
.addMultibinding<Feature, StreamerSockets>()
- .addMultibinding<Feature, WebRtcServer>()
- .addMultibinding<Feature, VncServer>();
+ .addMultibinding<Feature, WebRtcServer>();
}
} // namespace cuttlefish
diff --git a/host/commands/start/Android.bp b/host/commands/start/Android.bp
index 966c5f1..82d1327 100644
--- a/host/commands/start/Android.bp
+++ b/host/commands/start/Android.bp
@@ -19,6 +19,7 @@
cc_binary {
name: "cvd_internal_start",
+ symlinks: ["launch_cvd"],
srcs: [
"filesystem_explorer.cc",
"flag_forwarder.cc",
diff --git a/host/commands/status/Android.bp b/host/commands/status/Android.bp
index 6456d7a..4ce0e8c 100644
--- a/host/commands/status/Android.bp
+++ b/host/commands/status/Android.bp
@@ -19,6 +19,7 @@
cc_binary {
name: "cvd_internal_status",
+ symlinks: ["cvd_status"],
srcs: [
"main.cc",
],
diff --git a/host/commands/stop/Android.bp b/host/commands/stop/Android.bp
index 90bea87..7d705fd 100644
--- a/host/commands/stop/Android.bp
+++ b/host/commands/stop/Android.bp
@@ -19,6 +19,7 @@
cc_binary {
name: "cvd_internal_stop",
+ symlinks: ["stop_cvd"],
srcs: [
"main.cc",
],
diff --git a/host/frontend/vnc_server/Android.bp b/host/frontend/vnc_server/Android.bp
deleted file mode 100644
index 6f92dc0..0000000
--- a/host/frontend/vnc_server/Android.bp
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// Copyright (C) 2017 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_binary {
- name: "vnc_server",
- srcs: [
- "blackboard.cpp",
- "frame_buffer_watcher.cpp",
- "jpeg_compressor.cpp",
- "main.cpp",
- "simulated_hw_composer.cpp",
- "virtual_inputs.cpp",
- "vnc_client_connection.cpp",
- "vnc_server.cpp",
- ],
- shared_libs: [
- "libext2_blkid",
- "android.hardware.keymaster@4.0",
- "libcrypto",
- "libcuttlefish_fs",
- "libcuttlefish_utils",
- "libbase",
- "libjsoncpp",
- "liblog",
- ],
- header_libs: [
- "libcuttlefish_confui_host_headers",
- ],
- static_libs: [
- "libcuttlefish_host_config",
- "libcuttlefish_screen_connector",
- "libcuttlefish_wayland_server",
- "libcuttlefish_confui",
- "libcuttlefish_confui_host",
- "libft2.nodep",
- "libteeui",
- "libteeui_localization",
- "libffi",
- "libjpeg",
- "libgflags",
- "libwayland_crosvm_gpu_display_extension_server_protocols",
- "libwayland_extension_server_protocols",
- "libwayland_server",
- ],
- defaults: ["cuttlefish_host"],
-}
diff --git a/host/frontend/vnc_server/blackboard.cpp b/host/frontend/vnc_server/blackboard.cpp
deleted file mode 100644
index 91a8d1e..0000000
--- a/host/frontend/vnc_server/blackboard.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "host/frontend/vnc_server/blackboard.h"
-
-#include <algorithm>
-#include <utility>
-
-#include <gflags/gflags.h>
-#include <android-base/logging.h>
-#include "host/frontend/vnc_server/frame_buffer_watcher.h"
-
-DEFINE_bool(debug_blackboard, false,
- "Turn on detailed logging for the blackboard");
-
-#define DLOG(LEVEL) \
- if (FLAGS_debug_blackboard) LOG(LEVEL)
-
-using cuttlefish::vnc::BlackBoard;
-using cuttlefish::vnc::Stripe;
-
-cuttlefish::vnc::SeqNumberVec cuttlefish::vnc::MakeSeqNumberVec() {
- return SeqNumberVec(FrameBufferWatcher::StripesPerFrame());
-}
-
-void BlackBoard::NewStripeReady(int index, StripeSeqNumber seq_num) {
- std::lock_guard<std::mutex> guard(m_);
- DLOG(INFO) << "new stripe arrived from frame watcher";
- auto& current_seq_num = most_recent_stripe_seq_nums_[index];
- current_seq_num = std::max(current_seq_num, seq_num);
- for (auto& client : clients_) {
- if (client.second.ready_to_receive) {
- client.second.new_frame_cv.notify_one();
- }
- }
-}
-
-void BlackBoard::Register(const VncClientConnection* conn) {
- {
- std::lock_guard<std::mutex> guard(m_);
- CHECK(!clients_.count(conn));
- clients_[conn]; // constructs new state in place
- }
- new_client_cv_.notify_one();
-}
-
-void BlackBoard::Unregister(const VncClientConnection* conn) {
- std::lock_guard<std::mutex> guard(m_);
- CHECK(clients_.count(conn));
- clients_.erase(clients_.find(conn));
-}
-
-bool BlackBoard::NoNewStripesFor(const SeqNumberVec& seq_nums) const {
- CHECK(seq_nums.size() == most_recent_stripe_seq_nums_.size());
- for (auto state_seq_num = seq_nums.begin(),
- held_seq_num = most_recent_stripe_seq_nums_.begin();
- state_seq_num != seq_nums.end(); ++state_seq_num, ++held_seq_num) {
- if (*state_seq_num < *held_seq_num) {
- return false;
- }
- }
- return true;
-}
-
-cuttlefish::vnc::StripePtrVec BlackBoard::WaitForSenderWork(
- const VncClientConnection* conn) {
- std::unique_lock<std::mutex> guard(m_);
- auto& state = GetStateForClient(conn);
- DLOG(INFO) << "Waiting for stripe...";
- while (!state.closed &&
- (!state.ready_to_receive || NoNewStripesFor(state.stripe_seq_nums))) {
- state.new_frame_cv.wait(guard);
- }
- DLOG(INFO) << "At least one new stripe is available, should unblock " << conn;
- state.ready_to_receive = false;
- auto new_stripes = frame_buffer_watcher_->StripesNewerThan(
- state.orientation, state.stripe_seq_nums);
- for (auto& s : new_stripes) {
- state.stripe_seq_nums[s->index] = s->seq_number;
- }
- return new_stripes;
-}
-
-void BlackBoard::WaitForAtLeastOneClientConnection() {
- std::unique_lock<std::mutex> guard(m_);
- while (clients_.empty()) {
- new_client_cv_.wait(guard);
- }
-}
-
-void BlackBoard::SetOrientation(const VncClientConnection* conn,
- ScreenOrientation orientation) {
- std::lock_guard<std::mutex> guard(m_);
- auto& state = GetStateForClient(conn);
- state.orientation = orientation;
- // After an orientation change the vnc client will need all stripes from
- // the new orientation, regardless of age.
- ResetToZero(&state.stripe_seq_nums);
-}
-
-void BlackBoard::SignalClientNeedsEntireScreen(
- const VncClientConnection* conn) {
- std::lock_guard<std::mutex> guard(m_);
- ResetToZero(&GetStateForClient(conn).stripe_seq_nums);
-}
-
-void BlackBoard::ResetToZero(SeqNumberVec* seq_nums) {
- seq_nums->assign(FrameBufferWatcher::StripesPerFrame(), StripeSeqNumber{});
-}
-
-void BlackBoard::FrameBufferUpdateRequestReceived(
- const VncClientConnection* conn) {
- std::lock_guard<std::mutex> guard(m_);
- DLOG(INFO) << "Received frame buffer update request";
- auto& state = GetStateForClient(conn);
- state.ready_to_receive = true;
- state.new_frame_cv.notify_one();
-}
-
-void BlackBoard::StopWaiting(const VncClientConnection* conn) {
- std::lock_guard<std::mutex> guard(m_);
- auto& state = GetStateForClient(conn);
- state.closed = true;
- // Wake up the thread that might be in WaitForSenderWork()
- state.new_frame_cv.notify_one();
-}
-
-void BlackBoard::set_frame_buffer_watcher(
- cuttlefish::vnc::FrameBufferWatcher* frame_buffer_watcher) {
- std::lock_guard<std::mutex> guard(m_);
- frame_buffer_watcher_ = frame_buffer_watcher;
-}
-
-void BlackBoard::set_jpeg_quality_level(int quality_level) {
- // NOTE all vnc clients share a common jpeg quality level because the
- // server doesn't compress per-client. The quality level for all clients
- // will be whatever the most recent set was by any client.
- std::lock_guard<std::mutex> guard(m_);
- if (quality_level < kJpegMinQualityEncoding ||
- quality_level > kJpegMaxQualityEncoding) {
- LOG(WARNING) << "Bogus jpeg quality level: " << quality_level
- << ". Quality must be in range [" << kJpegMinQualityEncoding
- << ", " << kJpegMaxQualityEncoding << "]";
- return;
- }
- jpeg_quality_level_ = 55 + (5 * (quality_level + 32));
- DLOG(INFO) << "jpeg quality level set to " << jpeg_quality_level_ << "%";
-}
-
-BlackBoard::ClientFBUState& BlackBoard::GetStateForClient(
- const VncClientConnection* conn) {
- CHECK(clients_.count(conn));
- return clients_[conn];
-}
diff --git a/host/frontend/vnc_server/blackboard.h b/host/frontend/vnc_server/blackboard.h
deleted file mode 100644
index af4baea..0000000
--- a/host/frontend/vnc_server/blackboard.h
+++ /dev/null
@@ -1,113 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-
-#include <condition_variable>
-#include <memory>
-#include <mutex>
-#include <unordered_map>
-
-#include "common/libs/concurrency/thread_annotations.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-
-namespace cuttlefish {
-namespace vnc {
-
-class VncClientConnection;
-class FrameBufferWatcher;
-using StripePtrVec = std::vector<std::shared_ptr<const Stripe>>;
-using SeqNumberVec = std::vector<StripeSeqNumber>;
-
-SeqNumberVec MakeSeqNumberVec();
-
-class BlackBoard {
- private:
- struct ClientFBUState {
- bool ready_to_receive{};
- ScreenOrientation orientation{};
- std::condition_variable new_frame_cv;
- SeqNumberVec stripe_seq_nums = MakeSeqNumberVec();
- bool closed{};
- };
-
- public:
- class Registerer {
- public:
- Registerer(BlackBoard* bb, const VncClientConnection* conn)
- : bb_{bb}, conn_{conn} {
- bb->Register(conn);
- }
- ~Registerer() { bb_->Unregister(conn_); }
- Registerer(const Registerer&) = delete;
- Registerer& operator=(const Registerer&) = delete;
-
- private:
- BlackBoard* bb_{};
- const VncClientConnection* conn_{};
- };
-
- BlackBoard() = default;
- BlackBoard(const BlackBoard&) = delete;
- BlackBoard& operator=(const BlackBoard&) = delete;
-
- bool NoNewStripesFor(const SeqNumberVec& seq_nums) const REQUIRES(m_);
- void NewStripeReady(int index, StripeSeqNumber seq_num);
- void Register(const VncClientConnection* conn);
- void Unregister(const VncClientConnection* conn);
-
- StripePtrVec WaitForSenderWork(const VncClientConnection* conn);
-
- void WaitForAtLeastOneClientConnection();
-
- void FrameBufferUpdateRequestReceived(const VncClientConnection* conn);
- // Setting orientation implies needing the entire screen
- void SetOrientation(const VncClientConnection* conn,
- ScreenOrientation orientation);
- void SignalClientNeedsEntireScreen(const VncClientConnection* conn);
-
- void StopWaiting(const VncClientConnection* conn);
-
- void set_frame_buffer_watcher(FrameBufferWatcher* frame_buffer_watcher);
-
- // quality_level must be the value received from the client, in the range
- // [kJpegMinQualityEncoding, kJpegMaxQualityEncoding], else it is ignored.
- void set_jpeg_quality_level(int quality_level);
-
- int jpeg_quality_level() const {
- std::lock_guard<std::mutex> guard(m_);
- return jpeg_quality_level_;
- }
-
- private:
- ClientFBUState& GetStateForClient(const VncClientConnection* conn)
- REQUIRES(m_);
- static void ResetToZero(SeqNumberVec* seq_nums);
-
- mutable std::mutex m_;
- SeqNumberVec most_recent_stripe_seq_nums_ GUARDED_BY(m_) = MakeSeqNumberVec();
- std::unordered_map<const VncClientConnection*, ClientFBUState> clients_
- GUARDED_BY(m_);
- int jpeg_quality_level_ GUARDED_BY(m_) = 100;
- std::condition_variable new_client_cv_;
- // NOTE the FrameBufferWatcher pointer itself should be
- // guarded, but not the pointee.
- FrameBufferWatcher* frame_buffer_watcher_ GUARDED_BY(m_){};
-};
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/frame_buffer_watcher.cpp b/host/frontend/vnc_server/frame_buffer_watcher.cpp
deleted file mode 100644
index 659dbb6..0000000
--- a/host/frontend/vnc_server/frame_buffer_watcher.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "host/frontend/vnc_server/frame_buffer_watcher.h"
-
-#include <algorithm>
-#include <cstdint>
-#include <cstring>
-#include <iterator>
-#include <memory>
-#include <mutex>
-#include <thread>
-#include <utility>
-
-#include <android-base/logging.h>
-#include "host/frontend/vnc_server/vnc_utils.h"
-
-using cuttlefish::vnc::FrameBufferWatcher;
-
-FrameBufferWatcher::FrameBufferWatcher(BlackBoard* bb,
- ScreenConnector& screen_connector)
- : bb_{bb}, hwcomposer{screen_connector} {
- for (auto& stripes_vec : stripes_) {
- std::generate_n(std::back_inserter(stripes_vec),
- SimulatedHWComposer::NumberOfStripes(),
- std::make_shared<Stripe>);
- }
- bb_->set_frame_buffer_watcher(this);
- auto num_workers = std::max(std::thread::hardware_concurrency(), 1u);
- std::generate_n(std::back_inserter(workers_), num_workers, [this] {
- return std::thread{&FrameBufferWatcher::Worker, this};
- });
-}
-
-FrameBufferWatcher::~FrameBufferWatcher() {
- {
- std::lock_guard<std::mutex> guard(m_);
- closed_ = true;
- }
- for (auto& tid : workers_) {
- tid.join();
- }
-}
-
-bool FrameBufferWatcher::closed() const {
- std::lock_guard<std::mutex> guard(m_);
- return closed_;
-}
-
-cuttlefish::vnc::Stripe FrameBufferWatcher::Rotated(Stripe stripe) {
- if (stripe.orientation == ScreenOrientation::Landscape) {
- LOG(FATAL) << "Rotating a landscape stripe, this is a mistake";
- }
- auto w = stripe.width;
- auto s = stripe.stride;
- auto h = stripe.height;
- const auto& raw = stripe.raw_data;
- Message rotated(raw.size(), 0xAA);
- for (std::uint16_t i = 0; i < w; ++i) {
- for (std::uint16_t j = 0; j < h; ++j) {
- size_t to = (i * h + j) * ScreenConnectorInfo::BytesPerPixel();
- size_t from = (w - (i + 1)) * ScreenConnectorInfo::BytesPerPixel() + s * j;
- CHECK(from < raw.size());
- CHECK(to < rotated.size());
- std::memcpy(&rotated[to], &raw[from], ScreenConnectorInfo::BytesPerPixel());
- }
- }
- std::swap(stripe.x, stripe.y);
- std::swap(stripe.width, stripe.height);
- // The new stride after rotating is the height, as it is not aligned again.
- stripe.stride = stripe.width * ScreenConnectorInfo::BytesPerPixel();
- stripe.raw_data = std::move(rotated);
- stripe.orientation = ScreenOrientation::Landscape;
- return stripe;
-}
-
-bool FrameBufferWatcher::StripeIsDifferentFromPrevious(
- const Stripe& stripe) const {
- return Stripes(stripe.orientation)[stripe.index]->raw_data != stripe.raw_data;
-}
-
-cuttlefish::vnc::StripePtrVec FrameBufferWatcher::StripesNewerThan(
- ScreenOrientation orientation, const SeqNumberVec& seq_numbers) const {
- std::lock_guard<std::mutex> guard(stripes_lock_);
- const auto& stripes = Stripes(orientation);
- CHECK(seq_numbers.size() == stripes.size());
- StripePtrVec new_stripes;
- auto seq_number_it = seq_numbers.begin();
- std::copy_if(stripes.begin(), stripes.end(), std::back_inserter(new_stripes),
- [seq_number_it](const StripePtrVec::value_type& s) mutable {
- return *(seq_number_it++) < s->seq_number;
- });
- return new_stripes;
-}
-
-cuttlefish::vnc::StripePtrVec& FrameBufferWatcher::Stripes(
- ScreenOrientation orientation) {
- return stripes_[static_cast<int>(orientation)];
-}
-
-const cuttlefish::vnc::StripePtrVec& FrameBufferWatcher::Stripes(
- ScreenOrientation orientation) const {
- return stripes_[static_cast<int>(orientation)];
-}
-
-bool FrameBufferWatcher::UpdateMostRecentSeqNumIfStripeIsNew(
- const Stripe& stripe) {
- if (most_recent_identical_stripe_seq_nums_[stripe.index] <=
- stripe.seq_number) {
- most_recent_identical_stripe_seq_nums_[stripe.index] = stripe.seq_number;
- return true;
- }
- return false;
-}
-
-bool FrameBufferWatcher::UpdateStripeIfStripeIsNew(
- const std::shared_ptr<const Stripe>& stripe) {
- std::lock_guard<std::mutex> guard(stripes_lock_);
- if (UpdateMostRecentSeqNumIfStripeIsNew(*stripe)) {
- Stripes(stripe->orientation)[stripe->index] = stripe;
- return true;
- }
- return false;
-}
-
-void FrameBufferWatcher::CompressStripe(JpegCompressor* jpeg_compressor,
- Stripe* stripe) {
- stripe->jpeg_data = jpeg_compressor->Compress(
- stripe->raw_data, bb_->jpeg_quality_level(), 0, 0, stripe->width,
- stripe->height, stripe->stride);
-}
-
-void FrameBufferWatcher::Worker() {
- JpegCompressor jpeg_compressor;
-#ifdef FUZZ_TEST_VNC
- std::default_random_engine e{std::random_device{}()};
- std::uniform_int_distribution<int> random{0, 2};
-#endif
- while (!closed()) {
- auto portrait_stripe = hwcomposer.GetNewStripe();
- if (closed()) {
- break;
- }
- {
- // TODO(haining) use if (with init) and else for c++17 instead of extra
- // scope and continue
- // if (std::lock_guard guard(stripes_lock_); /*condition*/) { }
- std::lock_guard<std::mutex> guard(stripes_lock_);
- if (!StripeIsDifferentFromPrevious(portrait_stripe)) {
- UpdateMostRecentSeqNumIfStripeIsNew(portrait_stripe);
- continue;
- }
- }
- auto seq_num = portrait_stripe.seq_number;
- auto index = portrait_stripe.index;
- auto landscape_stripe = Rotated(portrait_stripe);
- auto stripes = {std::make_shared<Stripe>(std::move(portrait_stripe)),
- std::make_shared<Stripe>(std::move(landscape_stripe))};
- for (auto& stripe : stripes) {
-#ifdef FUZZ_TEST_VNC
- if (random(e)) {
- usleep(10000);
- }
-#endif
- CompressStripe(&jpeg_compressor, stripe.get());
- }
- bool any_new_stripes = false;
- for (auto& stripe : stripes) {
- any_new_stripes = UpdateStripeIfStripeIsNew(stripe) || any_new_stripes;
- }
- if (any_new_stripes) {
- bb_->NewStripeReady(index, seq_num);
- }
- }
-}
-
-int FrameBufferWatcher::StripesPerFrame() {
- return SimulatedHWComposer::NumberOfStripes();
-}
diff --git a/host/frontend/vnc_server/frame_buffer_watcher.h b/host/frontend/vnc_server/frame_buffer_watcher.h
deleted file mode 100644
index b05f90b..0000000
--- a/host/frontend/vnc_server/frame_buffer_watcher.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <memory>
-#include <mutex>
-#include <thread>
-#include <utility>
-#include <vector>
-
-#include "common/libs/concurrency/thread_annotations.h"
-#include "host/frontend/vnc_server/blackboard.h"
-#include "host/frontend/vnc_server/jpeg_compressor.h"
-#include "host/frontend/vnc_server/simulated_hw_composer.h"
-#include "host/libs/screen_connector/screen_connector.h"
-
-namespace cuttlefish {
-namespace vnc {
-class FrameBufferWatcher {
- public:
- explicit FrameBufferWatcher(BlackBoard* bb,
- ScreenConnector& screen_connector);
- FrameBufferWatcher(const FrameBufferWatcher&) = delete;
- FrameBufferWatcher& operator=(const FrameBufferWatcher&) = delete;
- ~FrameBufferWatcher();
-
- StripePtrVec StripesNewerThan(ScreenOrientation orientation,
- const SeqNumberVec& seq_num) const;
-
- static int StripesPerFrame();
-
- private:
- static Stripe Rotated(Stripe stripe);
-
- bool closed() const;
- bool StripeIsDifferentFromPrevious(const Stripe& stripe) const
- REQUIRES(stripes_lock_);
- // returns true if stripe is still considered new and seq number was updated
- bool UpdateMostRecentSeqNumIfStripeIsNew(const Stripe& stripe)
- REQUIRES(stripes_lock_);
- // returns true if stripe is still considered new and was updated
- bool UpdateStripeIfStripeIsNew(const std::shared_ptr<const Stripe>& stripe)
- EXCLUDES(stripes_lock_);
- // Compresses stripe->raw_data to stripe->jpeg_data
- void CompressStripe(JpegCompressor* jpeg_compressor, Stripe* stripe);
- void Worker();
- void Updater();
-
- StripePtrVec& Stripes(ScreenOrientation orientation) REQUIRES(stripes_lock_);
- const StripePtrVec& Stripes(ScreenOrientation orientation) const
- REQUIRES(stripes_lock_);
-
- std::vector<std::thread> workers_;
- mutable std::mutex stripes_lock_;
- std::array<StripePtrVec, kNumOrientations> stripes_ GUARDED_BY(stripes_lock_);
- SeqNumberVec most_recent_identical_stripe_seq_nums_
- GUARDED_BY(stripes_lock_) = MakeSeqNumberVec();
- mutable std::mutex m_;
- bool closed_ GUARDED_BY(m_){};
- BlackBoard* bb_{};
- SimulatedHWComposer hwcomposer;
-};
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/jpeg_compressor.cpp b/host/frontend/vnc_server/jpeg_compressor.cpp
deleted file mode 100644
index 05013eb..0000000
--- a/host/frontend/vnc_server/jpeg_compressor.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <stdio.h> // stdio.h must appear before jpeglib.h
-#include <jpeglib.h>
-
-#include <android-base/logging.h>
-#include "host/frontend/vnc_server/jpeg_compressor.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-#include "host/libs/screen_connector/screen_connector.h"
-
-using cuttlefish::vnc::JpegCompressor;
-
-namespace {
-void InitCinfo(jpeg_compress_struct* cinfo, jpeg_error_mgr* err,
- std::uint16_t width, std::uint16_t height, int jpeg_quality) {
- cinfo->err = jpeg_std_error(err);
- jpeg_create_compress(cinfo);
-
- cinfo->image_width = width;
- cinfo->image_height = height;
- cinfo->input_components = cuttlefish::ScreenConnectorInfo::BytesPerPixel();
- cinfo->in_color_space = JCS_EXT_RGBX;
-
- jpeg_set_defaults(cinfo);
- jpeg_set_quality(cinfo, jpeg_quality, true);
-}
-} // namespace
-
-cuttlefish::Message JpegCompressor::Compress(const Message& frame,
- int jpeg_quality, std::uint16_t x,
- std::uint16_t y, std::uint16_t width,
- std::uint16_t height,
- int stride) {
- jpeg_compress_struct cinfo{};
- jpeg_error_mgr err{};
- InitCinfo(&cinfo, &err, width, height, jpeg_quality);
-
- auto* compression_buffer = buffer_.get();
- auto compression_buffer_size = buffer_capacity_;
- jpeg_mem_dest(&cinfo, &compression_buffer, &compression_buffer_size);
- jpeg_start_compress(&cinfo, true);
-
- while (cinfo.next_scanline < cinfo.image_height) {
- auto row = static_cast<JSAMPROW>(const_cast<std::uint8_t*>(
- &frame[(y * stride) +
- (cinfo.next_scanline * stride) +
- (x * cuttlefish::ScreenConnectorInfo::BytesPerPixel())]));
- jpeg_write_scanlines(&cinfo, &row, 1);
- }
- jpeg_finish_compress(&cinfo);
- jpeg_destroy_compress(&cinfo);
-
- UpdateBuffer(compression_buffer, compression_buffer_size);
- return {compression_buffer, compression_buffer + compression_buffer_size};
-}
-
-void JpegCompressor::UpdateBuffer(std::uint8_t* compression_buffer,
- unsigned long compression_buffer_size) {
- if (buffer_.get() != compression_buffer) {
- buffer_capacity_ = compression_buffer_size;
- buffer_.reset(compression_buffer);
- }
-}
diff --git a/host/frontend/vnc_server/jpeg_compressor.h b/host/frontend/vnc_server/jpeg_compressor.h
deleted file mode 100644
index b6ef487..0000000
--- a/host/frontend/vnc_server/jpeg_compressor.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <cstdint>
-#include <cstdlib>
-#include <memory>
-
-#include "host/frontend/vnc_server/vnc_utils.h"
-
-namespace cuttlefish {
-namespace vnc {
-
-// libjpeg-turbo with jpeg_mem_dest (using memory as a destination) is funky.
-// If you give it a buffer that is big enough it will use it.
-// If you give it a buffer that is too small, it will allocate a new buffer
-// but will NOT free the buffer you gave it.
-// This class keeps track of the capacity of the working buffer, and frees the
-// old buffer if libjpeg-turbo silently discards it.
-class JpegCompressor {
- public:
- Message Compress(const Message& frame, int jpeg_quality, std::uint16_t x,
- std::uint16_t y, std::uint16_t width, std::uint16_t height,
- int screen_width);
-
- private:
- void UpdateBuffer(std::uint8_t* compression_buffer,
- unsigned long compression_buffer_size);
- struct Freer {
- void operator()(void* p) const { std::free(p); }
- };
-
- std::unique_ptr<std::uint8_t, Freer> buffer_;
- unsigned long buffer_capacity_{};
-};
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/keysyms.h b/host/frontend/vnc_server/keysyms.h
deleted file mode 100644
index ddcc0e4..0000000
--- a/host/frontend/vnc_server/keysyms.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <cstdint>
-
-namespace cuttlefish {
-namespace xk {
-
-constexpr uint32_t BackSpace = 0xff08, Tab = 0xff09, Return = 0xff0d,
- Enter = Return, Escape = 0xff1b, MultiKey = 0xff20,
- Insert = 0xff63, Delete = 0xffff, Pause = 0xff13,
- Home = 0xff50, End = 0xff57, PageUp = 0xff55,
- PageDown = 0xff56, Left = 0xff51, Up = 0xff52,
- Right = 0xff53, Down = 0xff54, F1 = 0xffbe, F2 = 0xffbf,
- F3 = 0xffc0, F4 = 0xffc1, F5 = 0xffc2, F6 = 0xffc3,
- F7 = 0xffc4, F8 = 0xffc5, F9 = 0xffc6, F10 = 0xffc7,
- F11 = 0xffc8, F12 = 0xffc9, F13 = 0xffca, F14 = 0xffcb,
- F15 = 0xffcc, F16 = 0xffcd, F17 = 0xffce, F18 = 0xffcf,
- F19 = 0xffd0, F20 = 0xffd1, F21 = 0xffd2, F22 = 0xffd3,
- F23 = 0xffd4, F24 = 0xffd5, ShiftLeft = 0xffe1,
- ShiftRight = 0xffe2, ControlLeft = 0xffe3,
- ControlRight = 0xffe4, MetaLeft = 0xffe7, MetaRight = 0xffe8,
- AltLeft = 0xffe9, AltRight = 0xffea, CapsLock = 0xffe5,
- NumLock = 0xff7f, ScrollLock = 0xff14, Keypad0 = 0xffb0,
- Keypad1 = 0xffb1, Keypad2 = 0xffb2, Keypad3 = 0xffb3,
- Keypad4 = 0xffb4, Keypad5 = 0xffb5, Keypad6 = 0xffb6,
- Keypad7 = 0xffb7, Keypad8 = 0xffb8, Keypad9 = 0xffb9,
- KeypadMultiply = 0xffaa, KeypadSubtract = 0xffad,
- KeypadAdd = 0xffab, KeypadDecimal = 0xffae,
- KeypadEnter = 0xff8d, KeypadDivide = 0xffaf,
- KeypadEqual = 0xffbd, PlusMinus = 0xb1, SysReq = 0xff15,
- LineFeed = 0xff0a, KeypadSeparator = 0xffac, Yen = 0xa5,
- Cancel = 0xff69, Undo = 0xff65, Redo = 0xff66, Find = 0xff68,
- Print = 0xff61, VolumeDown = 0x1008ff11, Mute = 0x1008ff12,
- VolumeUp = 0x1008ff13, Menu = 0xff67,
- VNCMenu = 0xffed; // VNC seems to translate MENU to this
-
-} // namespace xk
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/main.cpp b/host/frontend/vnc_server/main.cpp
deleted file mode 100644
index e036b40..0000000
--- a/host/frontend/vnc_server/main.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <algorithm>
-#include <memory>
-#include <string>
-
-#include <gflags/gflags.h>
-
-#include "host/frontend/vnc_server/simulated_hw_composer.h"
-#include "host/frontend/vnc_server/vnc_server.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-#include "host/libs/config/logging.h"
-#include "host/libs/confui/host_mode_ctrl.h"
-#include "host/libs/confui/host_server.h"
-
-DEFINE_bool(agressive, false, "Whether to use agressive server");
-DEFINE_int32(frame_server_fd, -1, "");
-DEFINE_int32(port, 6444, "Port where to listen for connections");
-
-int main(int argc, char* argv[]) {
- cuttlefish::DefaultSubprocessLogging(argv);
- google::ParseCommandLineFlags(&argc, &argv, true);
-
- auto& host_mode_ctrl = cuttlefish::HostModeCtrl::Get();
- auto screen_connector_ptr = cuttlefish::vnc::ScreenConnector::Get(
- FLAGS_frame_server_fd, host_mode_ctrl);
- auto& screen_connector = *(screen_connector_ptr.get());
-
- // create confirmation UI service, giving host_mode_ctrl and
- // screen_connector
- // keep this singleton object alive until the webRTC process ends
- static auto& host_confui_server =
- cuttlefish::confui::HostServer::Get(host_mode_ctrl, screen_connector);
-
- host_confui_server.Start();
- // lint does not like the spelling of "agressive", so needs NOTYPO
- cuttlefish::vnc::VncServer vnc_server(FLAGS_port, FLAGS_agressive, // NOTYPO
- screen_connector, host_confui_server);
- vnc_server.MainLoop();
-}
diff --git a/host/frontend/vnc_server/mocks.h b/host/frontend/vnc_server/mocks.h
deleted file mode 100644
index e69eb43..0000000
--- a/host/frontend/vnc_server/mocks.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-struct GceFrameBuffer {
- typedef uint32_t Pixel;
-
- static const int kRedShift = 0;
- static const int kRedBits = 8;
- static const int kGreenShift = 8;
- static const int kGreenBits = 8;
- static const int kBlueShift = 16;
- static const int kBlueBits = 8;
- static const int kAlphaShift = 24;
- static const int kAlphaBits = 8;
-};
-
-// Sensors
-struct gce_sensors_message {
- static constexpr const char* const kSensorsHALSocketName = "";
-};
diff --git a/host/frontend/vnc_server/simulated_hw_composer.cpp b/host/frontend/vnc_server/simulated_hw_composer.cpp
deleted file mode 100644
index 6919264..0000000
--- a/host/frontend/vnc_server/simulated_hw_composer.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "host/frontend/vnc_server/simulated_hw_composer.h"
-
-#include "host/frontend/vnc_server/vnc_utils.h"
-#include "host/libs/config/cuttlefish_config.h"
-
-using cuttlefish::vnc::SimulatedHWComposer;
-using ScreenConnector = cuttlefish::vnc::ScreenConnector;
-
-SimulatedHWComposer::SimulatedHWComposer(ScreenConnector& screen_connector)
- :
-#ifdef FUZZ_TEST_VNC
- engine_{std::random_device{}()},
-#endif
- stripes_(kMaxQueueElements, &SimulatedHWComposer::EraseHalfOfElements),
- screen_connector_(screen_connector) {
- stripe_maker_ = std::thread(&SimulatedHWComposer::MakeStripes, this);
- screen_connector_.SetCallback(std::move(GetScreenConnectorCallback()));
-}
-
-SimulatedHWComposer::~SimulatedHWComposer() {
- close();
- stripe_maker_.join();
-}
-
-cuttlefish::vnc::Stripe SimulatedHWComposer::GetNewStripe() {
- auto s = stripes_.Pop();
-#ifdef FUZZ_TEST_VNC
- if (random_(engine_)) {
- usleep(7000);
- stripes_.Push(std::move(s));
- s = stripes_.Pop();
- }
-#endif
- return s;
-}
-
-bool SimulatedHWComposer::closed() {
- std::lock_guard<std::mutex> guard(m_);
- return closed_;
-}
-
-void SimulatedHWComposer::close() {
- std::lock_guard<std::mutex> guard(m_);
- closed_ = true;
-}
-
-// Assuming the number of stripes is less than half the size of the queue
-// this will be safe as the newest stripes won't be lost. In the real
-// hwcomposer, where stripes are coming in a different order, the full
-// queue case would probably need a different approach to be safe.
-void SimulatedHWComposer::EraseHalfOfElements(
- ThreadSafeQueue<Stripe>::QueueImpl* q) {
- q->erase(q->begin(), std::next(q->begin(), kMaxQueueElements / 2));
-}
-
-SimulatedHWComposer::GenerateProcessedFrameCallback
-SimulatedHWComposer::GetScreenConnectorCallback() {
- return [](std::uint32_t display_number, std::uint32_t frame_w,
- std::uint32_t frame_h, std::uint32_t frame_stride_bytes,
- std::uint8_t* frame_bytes,
- cuttlefish::vnc::VncScProcessedFrame& processed_frame) {
- processed_frame.display_number_ = display_number;
- // TODO(171305898): handle multiple displays.
- if (display_number != 0) {
- // BUG 186580833: display_number comes from surface_id in crosvm
- // create_surface from virtio_gpu.rs set_scanout. We cannot use it as
- // the display number. Either crosvm virtio-gpu is incorrectly ignoring
- // scanout id and instead using a monotonically increasing surface id
- // number as the scanout resource is replaced over time, or frontend code
- // here is incorrectly assuming surface id == display id.
- display_number = 0;
- }
-
- const std::uint32_t frame_bpp = 4;
- const std::uint32_t frame_size_bytes = frame_h * frame_stride_bytes;
-
- auto& raw_screen = processed_frame.raw_screen_;
- raw_screen.assign(frame_bytes, frame_bytes + frame_size_bytes);
-
- static std::uint32_t next_frame_number = 0;
-
- const auto num_stripes = SimulatedHWComposer::kNumStripes;
- for (int i = 0; i < num_stripes; ++i) {
- std::uint16_t y = (frame_h / num_stripes) * i;
-
- // Last frames on the right and/or bottom handle extra pixels
- // when a screen dimension is not evenly divisible by Frame::kNumSlots.
- std::uint16_t height = frame_h / num_stripes +
- (i + 1 == num_stripes ? frame_h % num_stripes : 0);
- const auto* raw_start = &raw_screen[y * frame_w * frame_bpp];
- const auto* raw_end = raw_start + (height * frame_w * frame_bpp);
- // creating a named object and setting individual data members in order
- // to make klp happy
- // TODO (haining) construct this inside the call when not compiling
- // on klp
- Stripe s{};
- s.index = i;
- s.x = 0;
- s.y = y;
- s.width = frame_w;
- s.stride = frame_stride_bytes;
- s.height = height;
- s.frame_id = next_frame_number++;
- s.raw_data.assign(raw_start, raw_end);
- s.orientation = ScreenOrientation::Portrait;
- processed_frame.stripes_.push_back(std::move(s));
- }
-
- processed_frame.display_number_ = display_number;
- processed_frame.is_success_ = true;
- };
-}
-
-void SimulatedHWComposer::MakeStripes() {
- std::uint64_t stripe_seq_num = 1;
- /*
- * callback should be set before the first WaitForAtLeastOneClientConnection()
- * (b/178504150) and the first OnFrameAfter().
- */
- if (!screen_connector_.IsCallbackSet()) {
- LOG(FATAL) << "ScreenConnector callback hasn't been set before MakeStripes";
- }
- while (!closed()) {
- auto sim_hw_processed_frame = screen_connector_.OnNextFrame();
- // sim_hw_processed_frame has display number from the guest
- if (!sim_hw_processed_frame.is_success_) {
- continue;
- }
- while (!sim_hw_processed_frame.stripes_.empty()) {
- /*
- * ScreenConnector that supplies the frames into the queue
- * cannot be aware of stripe_seq_num. The callback was set at the
- * ScreenConnector creation time. ScreenConnector calls the callback
- * function autonomously to make the processed frames to supply the
- * queue with.
- *
- * Besides, ScreenConnector is not VNC specific. Thus, stripe_seq_num,
- * a VNC specific information, is maintained here.
- *
- * OnFrameAfter returns a sim_hw_processed_frame, that contains N consecutive stripes.
- * each stripe s has an invalid seq_number, default-initialzed
- * We set the field properly, and push to the stripes_
- */
- auto& s = sim_hw_processed_frame.stripes_.front();
- stripe_seq_num++;
- s.seq_number = StripeSeqNumber{stripe_seq_num};
- stripes_.Push(std::move(s));
- sim_hw_processed_frame.stripes_.pop_front();
- }
- }
-}
-
-int SimulatedHWComposer::NumberOfStripes() { return kNumStripes; }
diff --git a/host/frontend/vnc_server/simulated_hw_composer.h b/host/frontend/vnc_server/simulated_hw_composer.h
deleted file mode 100644
index 1146f45..0000000
--- a/host/frontend/vnc_server/simulated_hw_composer.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <condition_variable>
-#include <mutex>
-#ifdef FUZZ_TEST_VNC
-#include <random>
-#endif
-#include <thread>
-#include <deque>
-
-#include "common/libs/concurrency/thread_annotations.h"
-#include "common/libs/concurrency/thread_safe_queue.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-#include "host/libs/config/cuttlefish_config.h"
-#include "host/libs/screen_connector/screen_connector.h"
-
-namespace cuttlefish {
-namespace vnc {
-class SimulatedHWComposer {
- public:
- using GenerateProcessedFrameCallback = ScreenConnector::GenerateProcessedFrameCallback;
-
- SimulatedHWComposer(ScreenConnector& screen_connector);
- SimulatedHWComposer(const SimulatedHWComposer&) = delete;
- SimulatedHWComposer& operator=(const SimulatedHWComposer&) = delete;
- ~SimulatedHWComposer();
-
- Stripe GetNewStripe();
-
- // NOTE not constexpr on purpose
- static int NumberOfStripes();
-
- private:
- bool closed();
- void close();
- static void EraseHalfOfElements(ThreadSafeQueue<Stripe>::QueueImpl* q);
- void MakeStripes();
- GenerateProcessedFrameCallback GetScreenConnectorCallback();
-
-#ifdef FUZZ_TEST_VNC
- std::default_random_engine engine_;
- std::uniform_int_distribution<int> random_ =
- std::uniform_int_distribution<int>{0, 2};
-#endif
- static constexpr int kNumStripes = 8;
- constexpr static std::size_t kMaxQueueElements = 64;
- bool closed_ GUARDED_BY(m_){};
- std::mutex m_;
- ThreadSafeQueue<Stripe> stripes_;
- std::thread stripe_maker_;
- ScreenConnector& screen_connector_;
-};
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/virtual_inputs.cpp b/host/frontend/vnc_server/virtual_inputs.cpp
deleted file mode 100644
index 089cd24..0000000
--- a/host/frontend/vnc_server/virtual_inputs.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "host/frontend/vnc_server/virtual_inputs.h"
-
-#include <android-base/logging.h>
-#include <android-base/strings.h>
-#include <gflags/gflags.h>
-#include <linux/input.h>
-#include <linux/uinput.h>
-
-#include <cstdint>
-#include <mutex>
-#include <thread>
-#include "keysyms.h"
-
-#include "common/libs/confui/confui.h"
-#include "common/libs/fs/shared_select.h"
-#include "host/libs/config/cuttlefish_config.h"
-#include "host/libs/config/logging.h"
-
-using cuttlefish::vnc::VirtualInputs;
-
-DEFINE_string(touch_fds, "",
- "A list of fds for sockets where to accept touch connections");
-
-DEFINE_int32(keyboard_fd, -1,
- "A fd for a socket where to accept keyboard connections");
-
-DEFINE_bool(write_virtio_input, false,
- "Whether to write the virtio_input struct over the socket");
-
-namespace {
-// Necessary to define here as the virtio_input.h header is not available
-// in the host glibc.
-struct virtio_input_event {
- std::uint16_t type;
- std::uint16_t code;
- std::int32_t value;
-};
-
-void AddKeyMappings(std::map<uint32_t, uint16_t>* key_mapping) {
- (*key_mapping)[cuttlefish::xk::AltLeft] = KEY_LEFTALT;
- (*key_mapping)[cuttlefish::xk::ControlLeft] = KEY_LEFTCTRL;
- (*key_mapping)[cuttlefish::xk::ShiftLeft] = KEY_LEFTSHIFT;
- (*key_mapping)[cuttlefish::xk::AltRight] = KEY_RIGHTALT;
- (*key_mapping)[cuttlefish::xk::ControlRight] = KEY_RIGHTCTRL;
- (*key_mapping)[cuttlefish::xk::ShiftRight] = KEY_RIGHTSHIFT;
- (*key_mapping)[cuttlefish::xk::MetaLeft] = KEY_LEFTMETA;
- (*key_mapping)[cuttlefish::xk::MetaRight] = KEY_RIGHTMETA;
- (*key_mapping)[cuttlefish::xk::MultiKey] = KEY_COMPOSE;
-
- (*key_mapping)[cuttlefish::xk::CapsLock] = KEY_CAPSLOCK;
- (*key_mapping)[cuttlefish::xk::NumLock] = KEY_NUMLOCK;
- (*key_mapping)[cuttlefish::xk::ScrollLock] = KEY_SCROLLLOCK;
-
- (*key_mapping)[cuttlefish::xk::BackSpace] = KEY_BACKSPACE;
- (*key_mapping)[cuttlefish::xk::Tab] = KEY_TAB;
- (*key_mapping)[cuttlefish::xk::Return] = KEY_ENTER;
- (*key_mapping)[cuttlefish::xk::Escape] = KEY_ESC;
-
- (*key_mapping)[' '] = KEY_SPACE;
- (*key_mapping)['!'] = KEY_1;
- (*key_mapping)['"'] = KEY_APOSTROPHE;
- (*key_mapping)['#'] = KEY_3;
- (*key_mapping)['$'] = KEY_4;
- (*key_mapping)['%'] = KEY_5;
- (*key_mapping)['^'] = KEY_6;
- (*key_mapping)['&'] = KEY_7;
- (*key_mapping)['\''] = KEY_APOSTROPHE;
- (*key_mapping)['('] = KEY_9;
- (*key_mapping)[')'] = KEY_0;
- (*key_mapping)['*'] = KEY_8;
- (*key_mapping)['+'] = KEY_EQUAL;
- (*key_mapping)[','] = KEY_COMMA;
- (*key_mapping)['-'] = KEY_MINUS;
- (*key_mapping)['.'] = KEY_DOT;
- (*key_mapping)['/'] = KEY_SLASH;
- (*key_mapping)['0'] = KEY_0;
- (*key_mapping)['1'] = KEY_1;
- (*key_mapping)['2'] = KEY_2;
- (*key_mapping)['3'] = KEY_3;
- (*key_mapping)['4'] = KEY_4;
- (*key_mapping)['5'] = KEY_5;
- (*key_mapping)['6'] = KEY_6;
- (*key_mapping)['7'] = KEY_7;
- (*key_mapping)['8'] = KEY_8;
- (*key_mapping)['9'] = KEY_9;
- (*key_mapping)[':'] = KEY_SEMICOLON;
- (*key_mapping)[';'] = KEY_SEMICOLON;
- (*key_mapping)['<'] = KEY_COMMA;
- (*key_mapping)['='] = KEY_EQUAL;
- (*key_mapping)['>'] = KEY_DOT;
- (*key_mapping)['?'] = KEY_SLASH;
- (*key_mapping)['@'] = KEY_2;
- (*key_mapping)['A'] = KEY_A;
- (*key_mapping)['B'] = KEY_B;
- (*key_mapping)['C'] = KEY_C;
- (*key_mapping)['D'] = KEY_D;
- (*key_mapping)['E'] = KEY_E;
- (*key_mapping)['F'] = KEY_F;
- (*key_mapping)['G'] = KEY_G;
- (*key_mapping)['H'] = KEY_H;
- (*key_mapping)['I'] = KEY_I;
- (*key_mapping)['J'] = KEY_J;
- (*key_mapping)['K'] = KEY_K;
- (*key_mapping)['L'] = KEY_L;
- (*key_mapping)['M'] = KEY_M;
- (*key_mapping)['N'] = KEY_N;
- (*key_mapping)['O'] = KEY_O;
- (*key_mapping)['P'] = KEY_P;
- (*key_mapping)['Q'] = KEY_Q;
- (*key_mapping)['R'] = KEY_R;
- (*key_mapping)['S'] = KEY_S;
- (*key_mapping)['T'] = KEY_T;
- (*key_mapping)['U'] = KEY_U;
- (*key_mapping)['V'] = KEY_V;
- (*key_mapping)['W'] = KEY_W;
- (*key_mapping)['X'] = KEY_X;
- (*key_mapping)['Y'] = KEY_Y;
- (*key_mapping)['Z'] = KEY_Z;
- (*key_mapping)['['] = KEY_LEFTBRACE;
- (*key_mapping)['\\'] = KEY_BACKSLASH;
- (*key_mapping)[']'] = KEY_RIGHTBRACE;
- (*key_mapping)['-'] = KEY_MINUS;
- (*key_mapping)['_'] = KEY_MINUS;
- (*key_mapping)['`'] = KEY_GRAVE;
- (*key_mapping)['a'] = KEY_A;
- (*key_mapping)['b'] = KEY_B;
- (*key_mapping)['c'] = KEY_C;
- (*key_mapping)['d'] = KEY_D;
- (*key_mapping)['e'] = KEY_E;
- (*key_mapping)['f'] = KEY_F;
- (*key_mapping)['g'] = KEY_G;
- (*key_mapping)['h'] = KEY_H;
- (*key_mapping)['i'] = KEY_I;
- (*key_mapping)['j'] = KEY_J;
- (*key_mapping)['k'] = KEY_K;
- (*key_mapping)['l'] = KEY_L;
- (*key_mapping)['m'] = KEY_M;
- (*key_mapping)['n'] = KEY_N;
- (*key_mapping)['o'] = KEY_O;
- (*key_mapping)['p'] = KEY_P;
- (*key_mapping)['q'] = KEY_Q;
- (*key_mapping)['r'] = KEY_R;
- (*key_mapping)['s'] = KEY_S;
- (*key_mapping)['t'] = KEY_T;
- (*key_mapping)['u'] = KEY_U;
- (*key_mapping)['v'] = KEY_V;
- (*key_mapping)['w'] = KEY_W;
- (*key_mapping)['x'] = KEY_X;
- (*key_mapping)['y'] = KEY_Y;
- (*key_mapping)['z'] = KEY_Z;
- (*key_mapping)['{'] = KEY_LEFTBRACE;
- (*key_mapping)['\\'] = KEY_BACKSLASH;
- (*key_mapping)['|'] = KEY_BACKSLASH;
- (*key_mapping)['}'] = KEY_RIGHTBRACE;
- (*key_mapping)['~'] = KEY_GRAVE;
-
- (*key_mapping)[cuttlefish::xk::F1] = KEY_F1;
- (*key_mapping)[cuttlefish::xk::F2] = KEY_F2;
- (*key_mapping)[cuttlefish::xk::F3] = KEY_F3;
- (*key_mapping)[cuttlefish::xk::F4] = KEY_F4;
- (*key_mapping)[cuttlefish::xk::F5] = KEY_F5;
- (*key_mapping)[cuttlefish::xk::F6] = KEY_F6;
- (*key_mapping)[cuttlefish::xk::F7] = KEY_F7;
- (*key_mapping)[cuttlefish::xk::F8] = KEY_F8;
- (*key_mapping)[cuttlefish::xk::F9] = KEY_F9;
- (*key_mapping)[cuttlefish::xk::F10] = KEY_F10;
- (*key_mapping)[cuttlefish::xk::F11] = KEY_F11;
- (*key_mapping)[cuttlefish::xk::F12] = KEY_F12;
- (*key_mapping)[cuttlefish::xk::F13] = KEY_F13;
- (*key_mapping)[cuttlefish::xk::F14] = KEY_F14;
- (*key_mapping)[cuttlefish::xk::F15] = KEY_F15;
- (*key_mapping)[cuttlefish::xk::F16] = KEY_F16;
- (*key_mapping)[cuttlefish::xk::F17] = KEY_F17;
- (*key_mapping)[cuttlefish::xk::F18] = KEY_F18;
- (*key_mapping)[cuttlefish::xk::F19] = KEY_F19;
- (*key_mapping)[cuttlefish::xk::F20] = KEY_F20;
- (*key_mapping)[cuttlefish::xk::F21] = KEY_F21;
- (*key_mapping)[cuttlefish::xk::F22] = KEY_F22;
- (*key_mapping)[cuttlefish::xk::F23] = KEY_F23;
- (*key_mapping)[cuttlefish::xk::F24] = KEY_F24;
-
- (*key_mapping)[cuttlefish::xk::Keypad0] = KEY_KP0;
- (*key_mapping)[cuttlefish::xk::Keypad1] = KEY_KP1;
- (*key_mapping)[cuttlefish::xk::Keypad2] = KEY_KP2;
- (*key_mapping)[cuttlefish::xk::Keypad3] = KEY_KP3;
- (*key_mapping)[cuttlefish::xk::Keypad4] = KEY_KP4;
- (*key_mapping)[cuttlefish::xk::Keypad5] = KEY_KP5;
- (*key_mapping)[cuttlefish::xk::Keypad6] = KEY_KP6;
- (*key_mapping)[cuttlefish::xk::Keypad7] = KEY_KP7;
- (*key_mapping)[cuttlefish::xk::Keypad8] = KEY_KP8;
- (*key_mapping)[cuttlefish::xk::Keypad9] = KEY_KP9;
- (*key_mapping)[cuttlefish::xk::KeypadMultiply] = KEY_KPASTERISK;
- (*key_mapping)[cuttlefish::xk::KeypadSubtract] = KEY_KPMINUS;
- (*key_mapping)[cuttlefish::xk::KeypadAdd] = KEY_KPPLUS;
- (*key_mapping)[cuttlefish::xk::KeypadDecimal] = KEY_KPDOT;
- (*key_mapping)[cuttlefish::xk::KeypadEnter] = KEY_KPENTER;
- (*key_mapping)[cuttlefish::xk::KeypadDivide] = KEY_KPSLASH;
- (*key_mapping)[cuttlefish::xk::KeypadEqual] = KEY_KPEQUAL;
- (*key_mapping)[cuttlefish::xk::PlusMinus] = KEY_KPPLUSMINUS;
-
- (*key_mapping)[cuttlefish::xk::SysReq] = KEY_SYSRQ;
- (*key_mapping)[cuttlefish::xk::LineFeed] = KEY_LINEFEED;
- (*key_mapping)[cuttlefish::xk::Home] = KEY_HOME;
- (*key_mapping)[cuttlefish::xk::Up] = KEY_UP;
- (*key_mapping)[cuttlefish::xk::PageUp] = KEY_PAGEUP;
- (*key_mapping)[cuttlefish::xk::Left] = KEY_LEFT;
- (*key_mapping)[cuttlefish::xk::Right] = KEY_RIGHT;
- (*key_mapping)[cuttlefish::xk::End] = KEY_END;
- (*key_mapping)[cuttlefish::xk::Down] = KEY_DOWN;
- (*key_mapping)[cuttlefish::xk::PageDown] = KEY_PAGEDOWN;
- (*key_mapping)[cuttlefish::xk::Insert] = KEY_INSERT;
- (*key_mapping)[cuttlefish::xk::Delete] = KEY_DELETE;
- (*key_mapping)[cuttlefish::xk::Pause] = KEY_PAUSE;
- (*key_mapping)[cuttlefish::xk::KeypadSeparator] = KEY_KPCOMMA;
- (*key_mapping)[cuttlefish::xk::Yen] = KEY_YEN;
- (*key_mapping)[cuttlefish::xk::Cancel] = KEY_STOP;
- (*key_mapping)[cuttlefish::xk::Redo] = KEY_AGAIN;
- (*key_mapping)[cuttlefish::xk::Undo] = KEY_UNDO;
- (*key_mapping)[cuttlefish::xk::Find] = KEY_FIND;
- (*key_mapping)[cuttlefish::xk::Print] = KEY_PRINT;
- (*key_mapping)[cuttlefish::xk::VolumeDown] = KEY_VOLUMEDOWN;
- (*key_mapping)[cuttlefish::xk::Mute] = KEY_MUTE;
- (*key_mapping)[cuttlefish::xk::VolumeUp] = KEY_VOLUMEUP;
- (*key_mapping)[cuttlefish::xk::Menu] = KEY_MENU;
- (*key_mapping)[cuttlefish::xk::VNCMenu] = KEY_MENU;
-}
-
-void InitInputEvent(struct input_event* evt, uint16_t type, uint16_t code,
- int32_t value) {
- evt->type = type;
- evt->code = code;
- evt->value = value;
-}
-
-} // namespace
-
-class SocketVirtualInputs : public VirtualInputs {
- public:
- SocketVirtualInputs()
- : client_connector_([this]() { ClientConnectorLoop(); }) {}
-
- void GenerateKeyPressEvent(int key_code, bool down) override {
- struct input_event events[2];
- InitInputEvent(&events[0], EV_KEY, keymapping_[key_code], down);
- InitInputEvent(&events[1], EV_SYN, 0, 0);
-
- SendEvents(keyboard_socket_, events);
- }
-
- void PressPowerButton(bool down) override {
- struct input_event events[2];
- InitInputEvent(&events[0], EV_KEY, KEY_POWER, down);
- InitInputEvent(&events[1], EV_SYN, 0, 0);
-
- SendEvents(keyboard_socket_, events);
- }
-
- void HandlePointerEvent(bool touch_down, int x, int y) override {
- // TODO(b/124121375): Use multitouch when available
- struct input_event events[4];
- InitInputEvent(&events[0], EV_ABS, ABS_X, x);
- InitInputEvent(&events[1], EV_ABS, ABS_Y, y);
- InitInputEvent(&events[2], EV_KEY, BTN_TOUCH, touch_down);
- InitInputEvent(&events[3], EV_SYN, 0, 0);
-
- SendEvents(touch_socket_, events);
- }
-
- private:
- template<size_t num_events>
- void SendEvents(cuttlefish::SharedFD socket, struct input_event (&event_buffer)[num_events]) {
- std::lock_guard<std::mutex> lock(socket_mutex_);
- if (!socket->IsOpen()) {
- // This is unlikely as it would only happen between the start of the vnc
- // server and the connection of the VMM to the socket.
- // If it happens, just drop the events as the VM is not yet ready to
- // handle it.
- return;
- }
-
- if (FLAGS_write_virtio_input) {
- struct virtio_input_event virtio_events[num_events];
- for (size_t i = 0; i < num_events; i++) {
- virtio_events[i] = (struct virtio_input_event) {
- .type = event_buffer[i].type,
- .code = event_buffer[i].code,
- .value = event_buffer[i].value,
- };
- }
- auto ret = socket->Write(virtio_events, sizeof(virtio_events));
- if (ret < 0) {
- LOG(ERROR) << "Error sending input events: " << socket->StrError();
- }
- } else {
- auto ret = socket->Write(event_buffer, sizeof(event_buffer));
- if (ret < 0) {
- LOG(ERROR) << "Error sending input events: " << socket->StrError();
- }
- }
- }
-
- void ClientConnectorLoop() {
- auto touch_fd =
- std::stoi(android::base::Split(FLAGS_touch_fds, ",").front());
- auto touch_server = cuttlefish::SharedFD::Dup(touch_fd);
- close(touch_fd);
-
- auto keyboard_server = cuttlefish::SharedFD::Dup(FLAGS_keyboard_fd);
- close(FLAGS_keyboard_fd);
- FLAGS_keyboard_fd = -1;
- LOG(DEBUG) << "Input socket host accepting connections...";
-
- while (1) {
- cuttlefish::SharedFDSet read_set;
- read_set.Set(touch_server);
- read_set.Set(keyboard_server);
- cuttlefish::Select(&read_set, nullptr, nullptr, nullptr);
- {
- std::lock_guard<std::mutex> lock(socket_mutex_);
- if (read_set.IsSet(touch_server)) {
- touch_socket_ = cuttlefish::SharedFD::Accept(*touch_server);
- LOG(DEBUG) << "connected to touch";
- }
- if (read_set.IsSet(keyboard_server)) {
- keyboard_socket_ = cuttlefish::SharedFD::Accept(*keyboard_server);
- LOG(DEBUG) << "connected to keyboard";
- }
- }
- }
- }
- cuttlefish::SharedFD touch_socket_;
- cuttlefish::SharedFD keyboard_socket_;
- std::thread client_connector_;
- std::mutex socket_mutex_;
-};
-
-VirtualInputs::VirtualInputs() { AddKeyMappings(&keymapping_); }
-
-/**
- * Depending on the host mode (e.g. android, confirmation ui(tee), etc)
- * deliver the inputs to the right input implementation
- * e.g. ConfUI's input or regular socket based input
- */
-class VirtualInputDemux : public VirtualInputs {
- public:
- VirtualInputDemux(cuttlefish::confui::HostVirtualInput& confui_input)
- : confui_input_{confui_input} {}
- virtual ~VirtualInputDemux() = default;
-
- virtual void GenerateKeyPressEvent(int code, bool down) override;
- virtual void PressPowerButton(bool down) override;
- virtual void HandlePointerEvent(bool touch_down, int x, int y) override;
-
- private:
- SocketVirtualInputs socket_virtual_input_;
- cuttlefish::confui::HostVirtualInput& confui_input_;
-};
-
-void VirtualInputDemux::GenerateKeyPressEvent(int code, bool down) {
- // confui input is active only in the confirmation UI
- // also, socket virtual input should be inactive in the confirmation
- // UI session
- if (confui_input_.IsConfUiActive()) {
- if (down) {
- ConfUiLog(DEBUG) << "the key " << code
- << " is ignored in confirmation UI mode.";
- }
- return;
- }
- socket_virtual_input_.GenerateKeyPressEvent(code, down);
-}
-
-void VirtualInputDemux::PressPowerButton(bool down) {
- if (confui_input_.IsConfUiActive()) {
- if (down) {
- ConfUiLog(DEBUG) << "Power Buttown is ignored in confirmation UI mode.";
- }
- return;
- }
- socket_virtual_input_.PressPowerButton(down);
-}
-
-void VirtualInputDemux::HandlePointerEvent(bool touch_down, int x, int y) {
- if (confui_input_.IsConfUiActive()) {
- confui_input_.TouchEvent(x, y, touch_down);
- return;
- }
- socket_virtual_input_.HandlePointerEvent(touch_down, x, y);
-}
-
-std::shared_ptr<VirtualInputs> VirtualInputs::Get(
- cuttlefish::confui::HostVirtualInput& confui_input) {
- return std::make_shared<VirtualInputDemux>(confui_input);
-}
diff --git a/host/frontend/vnc_server/virtual_inputs.h b/host/frontend/vnc_server/virtual_inputs.h
deleted file mode 100644
index f30202e..0000000
--- a/host/frontend/vnc_server/virtual_inputs.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <map>
-#include <memory>
-#include <mutex>
-
-#include "host/libs/confui/host_virtual_input.h"
-#include "vnc_utils.h"
-
-namespace cuttlefish {
-namespace vnc {
-
-class VirtualInputs {
- public:
- static std::shared_ptr<VirtualInputs> Get(
- cuttlefish::confui::HostVirtualInput& confui_input);
-
- virtual ~VirtualInputs() = default;
-
- virtual void GenerateKeyPressEvent(int code, bool down) = 0;
- virtual void PressPowerButton(bool down) = 0;
- virtual void HandlePointerEvent(bool touch_down, int x, int y) = 0;
-
- protected:
- VirtualInputs();
-
- std::map<uint32_t, uint16_t> keymapping_;
-};
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/vnc_client_connection.cpp b/host/frontend/vnc_server/vnc_client_connection.cpp
deleted file mode 100644
index ce16ec8..0000000
--- a/host/frontend/vnc_server/vnc_client_connection.cpp
+++ /dev/null
@@ -1,685 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "host/frontend/vnc_server/vnc_client_connection.h"
-
-#include <netinet/in.h>
-#include <sys/time.h>
-
-#include <algorithm>
-#include <cmath>
-#include <cstdint>
-#include <cstring>
-#include <memory>
-#include <mutex>
-#include <string>
-#include <thread>
-#include <utility>
-#include <vector>
-
-#include <gflags/gflags.h>
-#include <android-base/logging.h>
-#include "common/libs/utils/tcp_socket.h"
-#include "host/frontend/vnc_server/keysyms.h"
-#include "host/frontend/vnc_server/mocks.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-#include "host/libs/config/cuttlefish_config.h"
-#include "host/libs/screen_connector/screen_connector.h"
-
-using cuttlefish::Message;
-using cuttlefish::vnc::Stripe;
-using cuttlefish::vnc::StripePtrVec;
-using cuttlefish::vnc::VncClientConnection;
-
-struct ScreenRegionView {
- using Pixel = uint32_t;
- static constexpr int kSwiftShaderPadding = 4;
- static constexpr int kRedShift = 0;
- static constexpr int kGreenShift = 8;
- static constexpr int kBlueShift = 16;
- static constexpr int kRedBits = 8;
- static constexpr int kGreenBits = 8;
- static constexpr int kBlueBits = 8;
-};
-
-DEFINE_bool(debug_client, false, "Turn on detailed logging for the client");
-
-#define DLOG(LEVEL) \
- if (FLAGS_debug_client) LOG(LEVEL)
-
-namespace {
-class BigEndianChecker {
- public:
- BigEndianChecker() {
- uint32_t u = 1;
- is_big_endian_ = *reinterpret_cast<const char*>(&u) == 0;
- }
- bool operator()() const { return is_big_endian_; }
-
- private:
- bool is_big_endian_{};
-};
-
-const BigEndianChecker ImBigEndian;
-
-constexpr int32_t kDesktopSizeEncoding = -223;
-constexpr int32_t kTightEncoding = 7;
-
-// These are the lengths not counting the first byte. The first byte
-// indicates the message type.
-constexpr size_t kSetPixelFormatLength = 19;
-constexpr size_t kFramebufferUpdateRequestLength = 9;
-constexpr size_t kSetEncodingsLength = 3; // more bytes follow
-constexpr size_t kKeyEventLength = 7;
-constexpr size_t kPointerEventLength = 5;
-constexpr size_t kClientCutTextLength = 7; // more bytes follow
-
-std::string HostName() {
- auto config = cuttlefish::CuttlefishConfig::Get();
- auto instance = config->ForDefaultInstance();
- return !config || instance.device_title().empty() ? std::string{"localhost"}
- : instance.device_title();
-}
-
-std::uint16_t uint16_tAt(const void* p) {
- std::uint16_t u{};
- std::memcpy(&u, p, sizeof u);
- return ntohs(u);
-}
-
-std::uint32_t uint32_tAt(const void* p) {
- std::uint32_t u{};
- std::memcpy(&u, p, sizeof u);
- return ntohl(u);
-}
-
-std::int32_t int32_tAt(const void* p) {
- std::uint32_t u{};
- std::memcpy(&u, p, sizeof u);
- u = ntohl(u);
- std::int32_t s{};
- std::memcpy(&s, &u, sizeof s);
- return s;
-}
-
-std::uint32_t RedVal(std::uint32_t pixel) {
- return (pixel >> ScreenRegionView::kRedShift) &
- ((0x1 << ScreenRegionView::kRedBits) - 1);
-}
-
-std::uint32_t BlueVal(std::uint32_t pixel) {
- return (pixel >> ScreenRegionView::kBlueShift) &
- ((0x1 << ScreenRegionView::kBlueBits) - 1);
-}
-
-std::uint32_t GreenVal(std::uint32_t pixel) {
- return (pixel >> ScreenRegionView::kGreenShift) &
- ((0x1 << ScreenRegionView::kGreenBits) - 1);
-}
-} // namespace
-namespace cuttlefish {
-namespace vnc {
-bool operator==(const VncClientConnection::FrameBufferUpdateRequest& lhs,
- const VncClientConnection::FrameBufferUpdateRequest& rhs) {
- return lhs.x_pos == rhs.x_pos && lhs.y_pos == rhs.y_pos &&
- lhs.width == rhs.width && lhs.height == rhs.height;
-}
-
-bool operator!=(const VncClientConnection::FrameBufferUpdateRequest& lhs,
- const VncClientConnection::FrameBufferUpdateRequest& rhs) {
- return !(lhs == rhs);
-}
-} // namespace vnc
-} // namespace cuttlefish
-
-VncClientConnection::VncClientConnection(
- ClientSocket client, std::shared_ptr<VirtualInputs> virtual_inputs,
- BlackBoard* bb, bool aggressive)
- : client_{std::move(client)}, virtual_inputs_{virtual_inputs}, bb_{bb} {
- frame_buffer_request_handler_tid_ = std::thread(
- &VncClientConnection::FrameBufferUpdateRequestHandler, this, aggressive);
-}
-
-VncClientConnection::~VncClientConnection() {
- {
- std::lock_guard<std::mutex> guard(m_);
- closed_ = true;
- }
- bb_->StopWaiting(this);
- frame_buffer_request_handler_tid_.join();
-}
-
-void VncClientConnection::StartSession() {
- LOG(INFO) << "Starting session";
- SetupProtocol();
- LOG(INFO) << "Protocol set up";
- if (client_.closed()) {
- return;
- }
- SetupSecurityType();
- LOG(INFO) << "Security type set";
- if (client_.closed()) {
- return;
- }
- GetClientInit();
- LOG(INFO) << "Gotten client init";
- if (client_.closed()) {
- return;
- }
- SendServerInit();
- LOG(INFO) << "Sent server init";
- if (client_.closed()) {
- return;
- }
- NormalSession();
- LOG(INFO) << "vnc session terminated";
-}
-
-bool VncClientConnection::closed() {
- std::lock_guard<std::mutex> guard(m_);
- return closed_;
-}
-
-void VncClientConnection::SetupProtocol() {
- static constexpr char kRFBVersion[] = "RFB 003.008\n";
- static constexpr char kRFBVersionOld[] = "RFB 003.003\n";
- static constexpr auto kVersionLen = (sizeof kRFBVersion) - 1;
- client_.SendNoSignal(reinterpret_cast<const std::uint8_t*>(kRFBVersion),
- kVersionLen);
- auto client_protocol = client_.Recv(kVersionLen);
- if (std::memcmp(&client_protocol[0], kRFBVersion,
- std::min(kVersionLen, client_protocol.size())) != 0) {
- if (!std::memcmp(
- &client_protocol[0],
- kRFBVersionOld,
- std::min(kVersionLen, client_protocol.size()))) {
- // We'll deal with V3.3 as well.
- client_is_old_ = true;
- return;
- }
-
- client_protocol.push_back('\0');
- LOG(ERROR) << "vnc client wants a different protocol: "
- << reinterpret_cast<const char*>(&client_protocol[0]);
- }
-}
-
-void VncClientConnection::SetupSecurityType() {
- if (client_is_old_) {
- static constexpr std::uint8_t kVNCSecurity[4] = { 0x00, 0x00, 0x00, 0x02 };
- client_.SendNoSignal(kVNCSecurity);
-
- static constexpr std::uint8_t kChallenge[16] =
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- client_.SendNoSignal(kChallenge);
-
- auto clientResponse = client_.Recv(16);
- (void)clientResponse; // Accept any response, we're not interested in actual security.
-
- static constexpr std::uint8_t kSuccess[4] = { 0x00, 0x00, 0x00, 0x00 };
- client_.SendNoSignal(kSuccess);
- return;
- }
-
- static constexpr std::uint8_t kNoneSecurity = 0x1;
- // The first '0x1' indicates the number of items that follow
- static constexpr std::uint8_t kOnlyNoneSecurity[] = {0x01, kNoneSecurity};
- client_.SendNoSignal(kOnlyNoneSecurity);
- auto client_security = client_.Recv(1);
- if (client_.closed()) {
- return;
- }
- if (client_security.front() != kNoneSecurity) {
- LOG(ERROR) << "vnc client is asking for security type "
- << static_cast<int>(client_security.front());
- }
- static constexpr std::uint8_t kZero[4] = {};
- client_.SendNoSignal(kZero);
-}
-
-void VncClientConnection::GetClientInit() {
- auto client_shared = client_.Recv(1);
-}
-
-void VncClientConnection::SendServerInit() {
- const std::string server_name = HostName();
- std::lock_guard<std::mutex> guard(m_);
- auto server_init = cuttlefish::CreateMessage(
- static_cast<std::uint16_t>(ScreenWidth()),
- static_cast<std::uint16_t>(ScreenHeight()), pixel_format_.bits_per_pixel,
- pixel_format_.depth, pixel_format_.big_endian, pixel_format_.true_color,
- pixel_format_.red_max, pixel_format_.green_max, pixel_format_.blue_max,
- pixel_format_.red_shift, pixel_format_.green_shift,
- pixel_format_.blue_shift, std::uint16_t{}, // padding
- std::uint8_t{}, // padding
- static_cast<std::uint32_t>(server_name.size()), server_name);
- client_.SendNoSignal(server_init);
-}
-
-Message VncClientConnection::MakeFrameBufferUpdateHeader(
- std::uint16_t num_stripes) {
- return cuttlefish::CreateMessage(std::uint8_t{0}, // message-type
- std::uint8_t{}, // padding
- std::uint16_t{num_stripes});
-}
-
-void VncClientConnection::AppendRawStripeHeader(Message* frame_buffer_update,
- const Stripe& stripe) {
- static constexpr int32_t kRawEncoding = 0;
- cuttlefish::AppendToMessage(frame_buffer_update, std::uint16_t{stripe.x},
- std::uint16_t{stripe.y}, std::uint16_t{stripe.width},
- std::uint16_t{stripe.height}, kRawEncoding);
-}
-
-void VncClientConnection::AppendJpegSize(Message* frame_buffer_update,
- size_t jpeg_size) {
- constexpr size_t kJpegSizeOneByteMax = 127;
- constexpr size_t kJpegSizeTwoByteMax = 16383;
- constexpr size_t kJpegSizeThreeByteMax = 4194303;
-
- if (jpeg_size <= kJpegSizeOneByteMax) {
- cuttlefish::AppendToMessage(frame_buffer_update,
- static_cast<std::uint8_t>(jpeg_size));
- } else if (jpeg_size <= kJpegSizeTwoByteMax) {
- auto sz = static_cast<std::uint32_t>(jpeg_size);
- cuttlefish::AppendToMessage(frame_buffer_update,
- static_cast<std::uint8_t>((sz & 0x7F) | 0x80),
- static_cast<std::uint8_t>((sz >> 7) & 0xFF));
- } else {
- if (jpeg_size > kJpegSizeThreeByteMax) {
- LOG(FATAL) << "jpeg size is too big: " << jpeg_size << " must be under "
- << kJpegSizeThreeByteMax;
- }
- const auto sz = static_cast<std::uint32_t>(jpeg_size);
- cuttlefish::AppendToMessage(frame_buffer_update,
- static_cast<std::uint8_t>((sz & 0x7F) | 0x80),
- static_cast<std::uint8_t>(((sz >> 7) & 0x7F) | 0x80),
- static_cast<std::uint8_t>((sz >> 14) & 0xFF));
- }
-}
-
-void VncClientConnection::AppendRawStripe(Message* frame_buffer_update,
- const Stripe& stripe) const {
- using Pixel = ScreenRegionView::Pixel;
- auto& fbu = *frame_buffer_update;
- AppendRawStripeHeader(&fbu, stripe);
- auto init_size = fbu.size();
- fbu.insert(fbu.end(), stripe.raw_data.begin(), stripe.raw_data.end());
- for (size_t i = init_size; i < fbu.size(); i += sizeof(Pixel)) {
- CHECK_LE(i + sizeof(Pixel), fbu.size());
- Pixel raw_pixel{};
- std::memcpy(&raw_pixel, &fbu[i], sizeof raw_pixel);
- auto red = RedVal(raw_pixel);
- auto green = GreenVal(raw_pixel);
- auto blue = BlueVal(raw_pixel);
- Pixel pixel = Pixel{red} << pixel_format_.red_shift |
- Pixel{blue} << pixel_format_.blue_shift |
- Pixel{green} << pixel_format_.green_shift;
-
- if (bool(pixel_format_.big_endian) != ImBigEndian()) {
- // flip them bits (refactor into function)
- auto p = reinterpret_cast<char*>(&pixel);
- std::swap(p[0], p[3]);
- std::swap(p[1], p[2]);
- }
- std::memcpy(&fbu[i], &pixel, sizeof pixel);
- }
-}
-
-Message VncClientConnection::MakeRawFrameBufferUpdate(
- const StripePtrVec& stripes) const {
- auto fbu =
- MakeFrameBufferUpdateHeader(static_cast<std::uint16_t>(stripes.size()));
- for (auto& stripe : stripes) {
- AppendRawStripe(&fbu, *stripe);
- }
- return fbu;
-}
-
-void VncClientConnection::AppendJpegStripeHeader(Message* frame_buffer_update,
- const Stripe& stripe) {
- static constexpr std::uint8_t kJpegEncoding = 0x90;
- cuttlefish::AppendToMessage(frame_buffer_update, stripe.x, stripe.y, stripe.width,
- stripe.height, kTightEncoding, kJpegEncoding);
- AppendJpegSize(frame_buffer_update, stripe.jpeg_data.size());
-}
-
-void VncClientConnection::AppendJpegStripe(Message* frame_buffer_update,
- const Stripe& stripe) {
- AppendJpegStripeHeader(frame_buffer_update, stripe);
- frame_buffer_update->insert(frame_buffer_update->end(),
- stripe.jpeg_data.begin(), stripe.jpeg_data.end());
-}
-
-Message VncClientConnection::MakeJpegFrameBufferUpdate(
- const StripePtrVec& stripes) {
- auto fbu =
- MakeFrameBufferUpdateHeader(static_cast<std::uint16_t>(stripes.size()));
- for (auto& stripe : stripes) {
- AppendJpegStripe(&fbu, *stripe);
- }
- return fbu;
-}
-
-Message VncClientConnection::MakeFrameBufferUpdate(
- const StripePtrVec& stripes) {
- return use_jpeg_compression_ ? MakeJpegFrameBufferUpdate(stripes)
- : MakeRawFrameBufferUpdate(stripes);
-}
-
-void VncClientConnection::FrameBufferUpdateRequestHandler(bool aggressive) {
- BlackBoard::Registerer reg(bb_, this);
-
- while (!closed()) {
- auto stripes = bb_->WaitForSenderWork(this);
- if (closed()) {
- break;
- }
- if (stripes.empty()) {
- LOG(FATAL) << "Got 0 stripes";
- }
- {
- // lock here so a portrait frame can't be sent after a landscape
- // DesktopSize update, or vice versa.
- std::lock_guard<std::mutex> guard(m_);
- DLOG(INFO) << "Sending update in "
- << (current_orientation_ == ScreenOrientation::Portrait
- ? "portrait"
- : "landscape")
- << " mode";
- client_.SendNoSignal(MakeFrameBufferUpdate(stripes));
- }
- if (aggressive) {
- bb_->FrameBufferUpdateRequestReceived(this);
- }
- }
-}
-
-void VncClientConnection::SendDesktopSizeUpdate() {
- static constexpr int32_t kDesktopSizeEncoding = -223;
- client_.SendNoSignal(cuttlefish::CreateMessage(
- std::uint8_t{0}, // message-type,
- std::uint8_t{}, // padding
- std::uint16_t{1}, // one pseudo rectangle
- std::uint16_t{0}, std::uint16_t{0},
- static_cast<std::uint16_t>(ScreenWidth()),
- static_cast<std::uint16_t>(ScreenHeight()), kDesktopSizeEncoding));
-}
-
-bool VncClientConnection::IsUrgent(
- const FrameBufferUpdateRequest& update_request) const {
- return !update_request.incremental ||
- update_request != previous_update_request_;
-}
-
-void VncClientConnection::HandleFramebufferUpdateRequest() {
- auto msg = client_.Recv(kFramebufferUpdateRequestLength);
- if (msg.size() != kFramebufferUpdateRequestLength) {
- return;
- }
- FrameBufferUpdateRequest fbur{msg[1] == 0, uint16_tAt(&msg[1]),
- uint16_tAt(&msg[3]), uint16_tAt(&msg[5]),
- uint16_tAt(&msg[7])};
- if (IsUrgent(fbur)) {
- bb_->SignalClientNeedsEntireScreen(this);
- }
- bb_->FrameBufferUpdateRequestReceived(this);
- previous_update_request_ = fbur;
-}
-
-void VncClientConnection::HandleSetEncodings() {
- auto msg = client_.Recv(kSetEncodingsLength);
- if (msg.size() != kSetEncodingsLength) {
- return;
- }
- auto count = uint16_tAt(&msg[1]);
- auto encodings = client_.Recv(count * sizeof(int32_t));
- if (encodings.size() % sizeof(int32_t) != 0) {
- return;
- }
- {
- std::lock_guard<std::mutex> guard(m_);
- use_jpeg_compression_ = false;
- }
- for (size_t i = 0; i < encodings.size(); i += sizeof(int32_t)) {
- auto enc = int32_tAt(&encodings[i]);
- DLOG(INFO) << "client requesting encoding: " << enc;
- if (enc == kTightEncoding) {
- // This is a deviation from the spec which says that if a jpeg quality
- // level is not specified, tight encoding won't use jpeg.
- std::lock_guard<std::mutex> guard(m_);
- use_jpeg_compression_ = true;
- }
- if (kJpegMinQualityEncoding <= enc && enc <= kJpegMaxQualityEncoding) {
- DLOG(INFO) << "jpeg compression level: " << enc;
- bb_->set_jpeg_quality_level(enc);
- }
- if (enc == kDesktopSizeEncoding) {
- supports_desktop_size_encoding_ = true;
- }
- }
-}
-
-void VncClientConnection::HandleSetPixelFormat() {
- std::lock_guard<std::mutex> guard(m_);
- auto msg = client_.Recv(kSetPixelFormatLength);
- if (msg.size() != kSetPixelFormatLength) {
- return;
- }
- pixel_format_.bits_per_pixel = msg[3];
- pixel_format_.depth = msg[4];
- pixel_format_.big_endian = msg[5];
- pixel_format_.true_color = msg[7];
- pixel_format_.red_max = uint16_tAt(&msg[8]);
- pixel_format_.green_max = uint16_tAt(&msg[10]);
- pixel_format_.blue_max = uint16_tAt(&msg[12]);
- pixel_format_.red_shift = msg[13];
- pixel_format_.green_shift = msg[14];
- pixel_format_.blue_shift = msg[15];
-}
-
-void VncClientConnection::HandlePointerEvent() {
- auto msg = client_.Recv(kPointerEventLength);
- if (msg.size() != kPointerEventLength) {
- return;
- }
- std::uint8_t button_mask = msg[0];
- auto x_pos = uint16_tAt(&msg[1]);
- auto y_pos = uint16_tAt(&msg[3]);
- {
- std::lock_guard<std::mutex> guard(m_);
- if (current_orientation_ == ScreenOrientation::Landscape) {
- std::tie(x_pos, y_pos) =
- std::make_pair(ScreenConnectorInfo::ScreenWidth(0) - y_pos, x_pos);
- }
- }
- virtual_inputs_->HandlePointerEvent(button_mask, x_pos, y_pos);
-}
-
-void VncClientConnection::UpdateAccelerometer(float /*x*/, float /*y*/,
- float /*z*/) {
- // TODO(jemoreira): Implement when vsoc sensor hal is updated
-}
-
-VncClientConnection::Coordinates VncClientConnection::CoordinatesForOrientation(
- ScreenOrientation orientation) const {
- // Compute the acceleration vector that we need to send to mimic
- // this change.
- constexpr float g = 9.81;
- constexpr float angle = 20.0;
- const float cos_angle = std::cos(angle / M_PI);
- const float sin_angle = std::sin(angle / M_PI);
- const float z = g * sin_angle;
- switch (orientation) {
- case ScreenOrientation::Portrait:
- return {0, g * cos_angle, z};
- case ScreenOrientation::Landscape:
- return {g * cos_angle, 0, z};
- }
-}
-
-int VncClientConnection::ScreenWidth() const {
- return current_orientation_ == ScreenOrientation::Portrait
- ? ScreenConnectorInfo::ScreenWidth(0)
- : ScreenConnectorInfo::ScreenHeight(0);
-}
-
-int VncClientConnection::ScreenHeight() const {
- return current_orientation_ == ScreenOrientation::Portrait
- ? ScreenConnectorInfo::ScreenHeight(0)
- : ScreenConnectorInfo::ScreenWidth(0);
-}
-
-void VncClientConnection::SetScreenOrientation(ScreenOrientation orientation) {
- std::lock_guard<std::mutex> guard(m_);
- auto coords = CoordinatesForOrientation(orientation);
- UpdateAccelerometer(coords.x, coords.y, coords.z);
- if (supports_desktop_size_encoding_) {
- auto previous_orientation = current_orientation_;
- current_orientation_ = orientation;
- if (current_orientation_ != previous_orientation &&
- supports_desktop_size_encoding_) {
- SendDesktopSizeUpdate();
- bb_->SetOrientation(this, current_orientation_);
- // TODO not sure if I should be sending a frame update along with this,
- // or just letting the next FBUR handle it. This seems to me like it's
- // sending one more frame buffer update than was requested, which is
- // maybe a violation of the spec?
- }
- }
-}
-
-bool VncClientConnection::RotateIfIsRotationCommand(std::uint32_t key) {
- // Due to different configurations on different platforms we're supporting
- // a set of options for rotating the screen. These are similar to what
- // the emulator supports and has supported.
- // ctrl+left and ctrl+right work on windows and linux
- // command+left and command+right work on Mac
- // ctrl+fn+F11 and ctrl+fn+F12 work when chromoting to ubuntu from a Mac
- if (!control_key_down_ && !meta_key_down_) {
- return false;
- }
- switch (key) {
- case cuttlefish::xk::Right:
- case cuttlefish::xk::F12:
- DLOG(INFO) << "switching to portrait";
- SetScreenOrientation(ScreenOrientation::Portrait);
- break;
- case cuttlefish::xk::Left:
- case cuttlefish::xk::F11:
- DLOG(INFO) << "switching to landscape";
- SetScreenOrientation(ScreenOrientation::Landscape);
- break;
- default:
- return false;
- }
- return true;
-}
-
-void VncClientConnection::HandleKeyEvent() {
- auto msg = client_.Recv(kKeyEventLength);
- if (msg.size() != kKeyEventLength) {
- return;
- }
-
- auto key = uint32_tAt(&msg[3]);
- bool key_down = msg[0];
- switch (key) {
- case cuttlefish::xk::ControlLeft:
- case cuttlefish::xk::ControlRight:
- control_key_down_ = key_down;
- break;
- case cuttlefish::xk::MetaLeft:
- case cuttlefish::xk::MetaRight:
- meta_key_down_ = key_down;
- break;
- case cuttlefish::xk::F5:
- key = cuttlefish::xk::Menu;
- break;
- case cuttlefish::xk::F7:
- virtual_inputs_->PressPowerButton(key_down);
- return;
- default:
- break;
- }
-
- if (RotateIfIsRotationCommand(key)) {
- return;
- }
-
- virtual_inputs_->GenerateKeyPressEvent(key, key_down);
-}
-
-void VncClientConnection::HandleClientCutText() {
- auto msg = client_.Recv(kClientCutTextLength);
- if (msg.size() != kClientCutTextLength) {
- return;
- }
- auto len = uint32_tAt(&msg[3]);
- client_.Recv(len);
-}
-
-void VncClientConnection::NormalSession() {
- static constexpr std::uint8_t kSetPixelFormatMessage{0};
- static constexpr std::uint8_t kSetEncodingsMessage{2};
- static constexpr std::uint8_t kFramebufferUpdateRequestMessage{3};
- static constexpr std::uint8_t kKeyEventMessage{4};
- static constexpr std::uint8_t kPointerEventMessage{5};
- static constexpr std::uint8_t kClientCutTextMessage{6};
- while (true) {
- if (client_.closed()) {
- return;
- }
- auto msg = client_.Recv(1);
- if (client_.closed()) {
- return;
- }
- auto msg_type = msg.front();
- DLOG(INFO) << "Received message type " << msg_type;
-
- switch (msg_type) {
- case kSetPixelFormatMessage:
- HandleSetPixelFormat();
- break;
-
- case kSetEncodingsMessage:
- HandleSetEncodings();
- break;
-
- case kFramebufferUpdateRequestMessage:
- HandleFramebufferUpdateRequest();
- break;
-
- case kKeyEventMessage:
- HandleKeyEvent();
- break;
-
- case kPointerEventMessage:
- HandlePointerEvent();
- break;
-
- case kClientCutTextMessage:
- HandleClientCutText();
- break;
-
- default:
- LOG(WARNING) << "message type not handled: "
- << static_cast<int>(msg_type);
- break;
- }
- }
-}
diff --git a/host/frontend/vnc_server/vnc_client_connection.h b/host/frontend/vnc_server/vnc_client_connection.h
deleted file mode 100644
index b26cf86..0000000
--- a/host/frontend/vnc_server/vnc_client_connection.h
+++ /dev/null
@@ -1,173 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "common/libs/concurrency/thread_annotations.h"
-#include "common/libs/fs/shared_fd.h"
-
-#include <cstdint>
-#include <memory>
-#include <mutex>
-#include <thread>
-#include <vector>
-
-#include "common/libs/utils/tcp_socket.h"
-#include "host/frontend/vnc_server/blackboard.h"
-#include "host/frontend/vnc_server/virtual_inputs.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-
-namespace cuttlefish {
-namespace vnc {
-
-class VncClientConnection {
- public:
- VncClientConnection(ClientSocket client,
- std::shared_ptr<VirtualInputs> virtual_inputs,
- BlackBoard* bb, bool aggressive);
- VncClientConnection(const VncClientConnection&) = delete;
- VncClientConnection& operator=(const VncClientConnection&) = delete;
- ~VncClientConnection();
-
- void StartSession();
-
- private:
- struct PixelFormat {
- std::uint8_t bits_per_pixel;
- std::uint8_t depth;
- std::uint8_t big_endian;
- std::uint8_t true_color;
- std::uint16_t red_max;
- std::uint16_t green_max;
- std::uint16_t blue_max;
- std::uint8_t red_shift;
- std::uint8_t green_shift;
- std::uint8_t blue_shift;
- };
-
- struct FrameBufferUpdateRequest {
- bool incremental;
- std::uint16_t x_pos;
- std::uint16_t y_pos;
- std::uint16_t width;
- std::uint16_t height;
- };
-
- friend bool operator==(const FrameBufferUpdateRequest&,
- const FrameBufferUpdateRequest&);
- friend bool operator!=(const FrameBufferUpdateRequest&,
- const FrameBufferUpdateRequest&);
-
- bool closed();
- void SetupProtocol();
- void SetupSecurityType();
-
- void GetClientInit();
-
- void SendServerInit() EXCLUDES(m_);
- static Message MakeFrameBufferUpdateHeader(std::uint16_t num_stripes);
-
- static void AppendRawStripeHeader(Message* frame_buffer_update,
- const Stripe& stripe);
- void AppendRawStripe(Message* frame_buffer_update, const Stripe& stripe) const
- REQUIRES(m_);
- Message MakeRawFrameBufferUpdate(const StripePtrVec& stripes) const
- REQUIRES(m_);
-
- static void AppendJpegSize(Message* frame_buffer_update, size_t jpeg_size);
- static void AppendJpegStripeHeader(Message* frame_buffer_update,
- const Stripe& stripe);
- static void AppendJpegStripe(Message* frame_buffer_update,
- const Stripe& stripe);
- static Message MakeJpegFrameBufferUpdate(const StripePtrVec& stripes);
-
- Message MakeFrameBufferUpdate(const StripePtrVec& frame) REQUIRES(m_);
-
- void FrameBufferUpdateRequestHandler(bool aggressive) EXCLUDES(m_);
-
- void SendDesktopSizeUpdate() REQUIRES(m_);
-
- bool IsUrgent(const FrameBufferUpdateRequest& update_request) const;
- static StripeSeqNumber MostRecentStripeSeqNumber(const StripePtrVec& stripes);
-
- void HandleFramebufferUpdateRequest() EXCLUDES(m_);
-
- void HandleSetEncodings();
-
- void HandleSetPixelFormat();
-
- void HandlePointerEvent() EXCLUDES(m_);
-
- void UpdateAccelerometer(float x, float y, float z);
-
- struct Coordinates {
- float x;
- float y;
- float z;
- };
-
- Coordinates CoordinatesForOrientation(ScreenOrientation orientation) const;
-
- int ScreenWidth() const REQUIRES(m_);
-
- int ScreenHeight() const REQUIRES(m_);
-
- void SetScreenOrientation(ScreenOrientation orientation) EXCLUDES(m_);
-
- // Returns true if key is special and the screen was rotated.
- bool RotateIfIsRotationCommand(std::uint32_t key);
-
- void HandleKeyEvent();
-
- void HandleClientCutText();
-
- void NormalSession();
-
- mutable std::mutex m_;
- ClientSocket client_;
- bool control_key_down_ = false;
- bool meta_key_down_ = false;
- std::shared_ptr<VirtualInputs> virtual_inputs_{};
-
- FrameBufferUpdateRequest previous_update_request_{};
- BlackBoard* bb_;
- bool use_jpeg_compression_ GUARDED_BY(m_) = false;
-
- std::thread frame_buffer_request_handler_tid_;
- bool closed_ GUARDED_BY(m_){};
-
- PixelFormat pixel_format_ GUARDED_BY(m_) = {
- std::uint8_t{32}, // bits per pixel
- std::uint8_t{24}, // depth
- std::uint8_t{0}, // big_endian
- std::uint8_t{1}, // true_color
- std::uint16_t{0xff}, // red_max, (maxes not used when true color flag is 0)
- std::uint16_t{0xff}, // green_max
- std::uint16_t{0xff}, // blue_max
- std::uint8_t{0}, // red_shift (shifts not used when true color flag is 0)
- std::uint8_t{8}, // green_shift
- std::uint8_t{16}, // blue_shift
- };
-
- bool supports_desktop_size_encoding_ = false;
- ScreenOrientation current_orientation_ GUARDED_BY(m_) =
- ScreenOrientation::Portrait;
-
- bool client_is_old_ = false;
-};
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/vnc_server.cpp b/host/frontend/vnc_server/vnc_server.cpp
deleted file mode 100644
index 08a4655..0000000
--- a/host/frontend/vnc_server/vnc_server.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "host/frontend/vnc_server/vnc_server.h"
-
-#include <memory>
-
-#include <android-base/logging.h>
-#include "common/libs/utils/tcp_socket.h"
-#include "host/frontend/vnc_server/blackboard.h"
-#include "host/frontend/vnc_server/frame_buffer_watcher.h"
-#include "host/frontend/vnc_server/jpeg_compressor.h"
-#include "host/frontend/vnc_server/virtual_inputs.h"
-#include "host/frontend/vnc_server/vnc_client_connection.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-
-using cuttlefish::vnc::VncServer;
-
-VncServer::VncServer(int port, bool aggressive,
- cuttlefish::vnc::ScreenConnector& screen_connector,
- cuttlefish::confui::HostVirtualInput& confui_input)
- : server_(port),
- virtual_inputs_(VirtualInputs::Get(confui_input)),
- frame_buffer_watcher_{&bb_, screen_connector},
- aggressive_{aggressive} {}
-
-void VncServer::MainLoop() {
- while (true) {
- LOG(DEBUG) << "Awaiting connections";
- auto connection = server_.Accept();
- LOG(DEBUG) << "Accepted a client connection";
- StartClient(std::move(connection));
- }
-}
-
-void VncServer::StartClient(ClientSocket sock) {
- std::thread t(&VncServer::StartClientThread, this, std::move(sock));
- t.detach();
-}
-
-void VncServer::StartClientThread(ClientSocket sock) {
- // NOTE if VncServer is expected to be destroyed, we have a problem here.
- // All of the client threads will be pointing to the VncServer's
- // data members. In the current setup, if the VncServer is destroyed with
- // clients still running, the clients will all be left with dangling
- // pointers.
- VncClientConnection client(std::move(sock), virtual_inputs_, &bb_,
- aggressive_);
- client.StartSession();
-}
diff --git a/host/frontend/vnc_server/vnc_server.h b/host/frontend/vnc_server/vnc_server.h
deleted file mode 100644
index 2751fd1..0000000
--- a/host/frontend/vnc_server/vnc_server.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <memory>
-#include <string>
-#include <thread>
-#include <utility>
-
-#include "common/libs/utils/tcp_socket.h"
-#include "host/frontend/vnc_server/blackboard.h"
-#include "host/frontend/vnc_server/frame_buffer_watcher.h"
-#include "host/frontend/vnc_server/jpeg_compressor.h"
-#include "host/frontend/vnc_server/virtual_inputs.h"
-#include "host/frontend/vnc_server/vnc_client_connection.h"
-#include "host/frontend/vnc_server/vnc_utils.h"
-#include "host/libs/confui/host_mode_ctrl.h"
-#include "host/libs/confui/host_virtual_input.h"
-#include "host/libs/screen_connector/screen_connector.h"
-
-namespace cuttlefish {
-namespace vnc {
-
-class VncServer {
- public:
- explicit VncServer(int port, bool aggressive,
- ScreenConnector& screen_connector,
- cuttlefish::confui::HostVirtualInput& confui_input);
-
- VncServer(const VncServer&) = delete;
- VncServer& operator=(const VncServer&) = delete;
-
- [[noreturn]] void MainLoop();
-
- private:
- void StartClient(ClientSocket sock);
-
- void StartClientThread(ClientSocket sock);
-
- ServerSocket server_;
-
- std::shared_ptr<VirtualInputs> virtual_inputs_;
- BlackBoard bb_;
-
- FrameBufferWatcher frame_buffer_watcher_;
- bool aggressive_{};
-};
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/vnc_server/vnc_utils.h b/host/frontend/vnc_server/vnc_utils.h
deleted file mode 100644
index 7ec19f7..0000000
--- a/host/frontend/vnc_server/vnc_utils.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2017 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.
- */
-
-#include <array>
-#include <cstdint>
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "common/libs/utils/size_utils.h"
-#include "common/libs/utils/tcp_socket.h"
-#include "host/libs/config/cuttlefish_config.h"
-#include "host/libs/screen_connector/screen_connector.h"
-
-namespace cuttlefish {
-namespace vnc {
-
-// TODO(haining) when the hwcomposer gives a sequence number type, use that
-// instead. It might just work to replace this class with a type alias
-// using StripeSeqNumber = whatever_the_hwcomposer_uses;
-class StripeSeqNumber {
- public:
- StripeSeqNumber() = default;
- explicit StripeSeqNumber(std::uint64_t t) : t_{t} {}
- bool operator<(const StripeSeqNumber& other) const { return t_ < other.t_; }
-
- bool operator<=(const StripeSeqNumber& other) const { return t_ <= other.t_; }
-
- private:
- std::uint64_t t_{};
-};
-
-constexpr int32_t kJpegMaxQualityEncoding = -23;
-constexpr int32_t kJpegMinQualityEncoding = -32;
-
-enum class ScreenOrientation { Portrait, Landscape };
-constexpr int kNumOrientations = 2;
-
-struct Stripe {
- int index = -1;
- std::uint64_t frame_id{};
- std::uint16_t x{};
- std::uint16_t y{};
- std::uint16_t width{};
- std::uint16_t stride{};
- std::uint16_t height{};
- Message raw_data{};
- Message jpeg_data{};
- StripeSeqNumber seq_number{};
- ScreenOrientation orientation{};
-};
-
-/**
- * ScreenConnectorImpl will generate this, and enqueue
- *
- * It's basically a (processed) frame, so it:
- * must be efficiently std::move-able
- * Also, for the sake of algorithm simplicity:
- * must be default-constructable & assignable
- *
- */
-struct VncScProcessedFrame : public ScreenConnectorFrameInfo {
- Message raw_screen_;
- std::deque<Stripe> stripes_;
- std::unique_ptr<VncScProcessedFrame> Clone() {
- VncScProcessedFrame* cloned_frame = new VncScProcessedFrame();
- cloned_frame->raw_screen_ = raw_screen_;
- cloned_frame->stripes_ = stripes_;
- return std::unique_ptr<VncScProcessedFrame>(cloned_frame);
- }
-};
-using ScreenConnector = cuttlefish::ScreenConnector<VncScProcessedFrame>;
-
-} // namespace vnc
-} // namespace cuttlefish
diff --git a/host/frontend/webrtc/audio_handler.cpp b/host/frontend/webrtc/audio_handler.cpp
index 1cd8938..20bbe14 100644
--- a/host/frontend/webrtc/audio_handler.cpp
+++ b/host/frontend/webrtc/audio_handler.cpp
@@ -344,8 +344,10 @@
stream_descs_[cmd.stream_id()].bits_per_sample = bits_per_sample;
stream_descs_[cmd.stream_id()].sample_rate = sample_rate;
stream_descs_[cmd.stream_id()].channels = channels;
+ // 10ms for playback and 20ms period for capture (10ms + previous leftover)
auto len10ms = (channels * (sample_rate / 100) * bits_per_sample) / 8;
- stream_descs_[cmd.stream_id()].buffer.Reset(len10ms);
+ auto len = IsCapture(cmd.stream_id()) ? 2 * len10ms : len10ms;
+ stream_descs_[cmd.stream_id()].buffer.Reset(len);
}
cmd.Reply(AudioStatus::VIRTIO_SND_S_OK);
}
@@ -484,18 +486,35 @@
buffer.SendStatus(AudioStatus::VIRTIO_SND_S_OK, 0, buffer.len());
return;
}
- auto bytes_per_sample = stream_desc.bits_per_sample / 8;
- auto samples_per_channel =
- buffer.len() / stream_desc.channels / bytes_per_sample;
+ const auto bytes_per_sample = stream_desc.bits_per_sample / 8;
+ const auto samples_per_channel = stream_desc.sample_rate / 100;
+ const auto bytes_per_request =
+ samples_per_channel * bytes_per_sample * stream_desc.channels;
bool muted = false;
- auto res = audio_source_->GetMoreAudioData(
- const_cast<uint8_t*>(buffer.get()), bytes_per_sample,
- samples_per_channel, stream_desc.channels, stream_desc.sample_rate,
- muted);
- if (res < 0) {
- // This is likely a recoverable error, log the error but don't let the VMM
- // know about it so that it doesn't crash.
- LOG(ERROR) << "Failed to receive audio data from client";
+ size_t bytes_read = 0;
+ auto& holding_buffer = stream_descs_[stream_id].buffer;
+ auto rx_buffer = const_cast<uint8_t*>(buffer.get());
+ while (bytes_read < buffer.len()) {
+ if (holding_buffer.freeCapacity() < bytes_per_request) {
+ LOG(ERROR) << "Buffer too small for receiving audio";
+ break;
+ }
+ auto pos = holding_buffer.end();
+ // First read to holding buffer...
+ auto res = audio_source_->GetMoreAudioData(
+ pos, bytes_per_sample, samples_per_channel, stream_desc.channels,
+ stream_desc.sample_rate, muted);
+ if (res < 0) {
+ // This is likely a recoverable error, log the error but don't let the
+ // VMM know about it so that it doesn't crash.
+ LOG(ERROR) << "Failed to receive audio data from client";
+ break;
+ }
+ auto bytes_received = res * bytes_per_sample * stream_desc.channels;
+ holding_buffer.count += bytes_received;
+ // ...then copy data to the rx buffer
+ bytes_read += holding_buffer.Take(rx_buffer + bytes_read,
+ buffer.len() - bytes_read);
}
}
buffer.SendStatus(AudioStatus::VIRTIO_SND_S_OK, 0, buffer.len());
@@ -514,12 +533,26 @@
return added_len;
}
+size_t AudioHandler::HoldingBuffer::Take(uint8_t* dst, size_t len) {
+ auto n = std::min(len, count);
+ std::copy(buffer.begin(), buffer.begin() + n, dst);
+ std::copy(buffer.begin() + n, buffer.end(), buffer.begin());
+ count -= n;
+ return n;
+}
+
bool AudioHandler::HoldingBuffer::empty() const { return count == 0; }
bool AudioHandler::HoldingBuffer::full() const {
return count == buffer.size();
}
+size_t AudioHandler::HoldingBuffer::freeCapacity() const {
+ return buffer.size() - count;
+}
+
uint8_t* AudioHandler::HoldingBuffer::data() { return buffer.data(); }
+uint8_t* AudioHandler::HoldingBuffer::end() { return &buffer[count]; }
+
} // namespace cuttlefish
diff --git a/host/frontend/webrtc/audio_handler.h b/host/frontend/webrtc/audio_handler.h
index 4da645c..fc4734a 100644
--- a/host/frontend/webrtc/audio_handler.h
+++ b/host/frontend/webrtc/audio_handler.h
@@ -35,9 +35,12 @@
void Reset(size_t size);
size_t Add(const volatile uint8_t* data, size_t max_len);
+ size_t Take(uint8_t* dst, size_t len);
bool empty() const;
bool full() const;
+ size_t freeCapacity() const;
uint8_t* data();
+ uint8_t* end();
};
struct StreamDesc {
std::mutex mtx;
diff --git a/host/libs/config/bootconfig_args.cpp b/host/libs/config/bootconfig_args.cpp
index ab136ab..5ee028b 100644
--- a/host/libs/config/bootconfig_args.cpp
+++ b/host/libs/config/bootconfig_args.cpp
@@ -160,8 +160,6 @@
bootconfig_args.push_back(
concat("androidboot.wifi_mac_prefix=", instance.wifi_mac_prefix()));
- bootconfig_args.push_back("androidboot.verifiedbootstate=orange");
-
// Non-native architecture implies a significantly slower execution speed, so
// set a large timeout multiplier.
if (!IsHostCompatible(config.target_arch())) {
diff --git a/host/libs/config/cuttlefish_config.cpp b/host/libs/config/cuttlefish_config.cpp
index 1f24462..8d693d9 100644
--- a/host/libs/config/cuttlefish_config.cpp
+++ b/host/libs/config/cuttlefish_config.cpp
@@ -290,14 +290,6 @@
return (*dictionary_)[kEnableGnssGrpcProxy].asBool();
}
-static constexpr char kEnableVncServer[] = "enable_vnc_server";
-bool CuttlefishConfig::enable_vnc_server() const {
- return (*dictionary_)[kEnableVncServer].asBool();
-}
-void CuttlefishConfig::set_enable_vnc_server(bool enable_vnc_server) {
- (*dictionary_)[kEnableVncServer] = enable_vnc_server;
-}
-
static constexpr char kEnableSandbox[] = "enable_sandbox";
void CuttlefishConfig::set_enable_sandbox(const bool enable_sandbox) {
(*dictionary_)[kEnableSandbox] = enable_sandbox;
@@ -844,6 +836,14 @@
return instances;
}
+std::vector<std::string> CuttlefishConfig::instance_dirs() const {
+ std::vector<std::string> result;
+ for (const auto& instance : Instances()) {
+ result.push_back(instance.instance_dir());
+ }
+ return result;
+}
+
int GetInstance() {
static int instance_id = InstanceFromEnvironment();
return instance_id;
diff --git a/host/libs/config/cuttlefish_config.h b/host/libs/config/cuttlefish_config.h
index e20de58..006d35f 100644
--- a/host/libs/config/cuttlefish_config.h
+++ b/host/libs/config/cuttlefish_config.h
@@ -136,9 +136,6 @@
void set_tpm_device(const std::string& tpm_device);
std::string tpm_device() const;
- void set_enable_vnc_server(bool enable_vnc_server);
- bool enable_vnc_server() const;
-
void set_enable_sandbox(const bool enable_sandbox);
bool enable_sandbox() const;
@@ -322,6 +319,7 @@
InstanceSpecific ForDefaultInstance() const;
std::vector<InstanceSpecific> Instances() const;
+ std::vector<std::string> instance_dirs() const;
// A view into an existing CuttlefishConfig object for a particular instance.
class InstanceSpecific {
@@ -341,8 +339,8 @@
// If any of the following port numbers is 0, the relevant service is not
// running on the guest.
- // Port number to connect to vnc server on the host
- int vnc_server_port() const;
+ // Port number for qemu to run a vnc server on the host
+ int qemu_vnc_server_port() const;
// Port number to connect to the tombstone receiver on the host
int tombstone_receiver_port() const;
// Port number to connect to the config server on the host
@@ -374,7 +372,6 @@
std::string rootcanal_default_commands_file() const;
std::string adb_device_name() const;
- std::string device_title() const;
std::string gnss_file_path() const;
std::string mobile_bridge_name() const;
std::string mobile_tap_name() const;
@@ -471,7 +468,7 @@
Json::Value* Dictionary();
public:
void set_serial_number(const std::string& serial_number);
- void set_vnc_server_port(int vnc_server_port);
+ void set_qemu_vnc_server_port(int qemu_vnc_server_port);
void set_tombstone_receiver_port(int tombstone_receiver_port);
void set_config_server_port(int config_server_port);
void set_frames_server_port(int config_server_port);
@@ -492,7 +489,6 @@
void set_rootcanal_config_file(const std::string& rootcanal_config_file);
void set_rootcanal_default_commands_file(
const std::string& rootcanal_default_commands_file);
- void set_device_title(const std::string& title);
void set_mobile_bridge_name(const std::string& mobile_bridge_name);
void set_mobile_tap_name(const std::string& mobile_tap_name);
void set_wifi_tap_name(const std::string& wifi_tap_name);
diff --git a/host/libs/config/cuttlefish_config_instance.cpp b/host/libs/config/cuttlefish_config_instance.cpp
index f4cd913..aa4a1b6 100644
--- a/host/libs/config/cuttlefish_config_instance.cpp
+++ b/host/libs/config/cuttlefish_config_instance.cpp
@@ -294,21 +294,13 @@
return "NO_ADB_MODE_SET_NO_VALID_DEVICE_NAME";
}
-static constexpr char kDeviceTitle[] = "device_title";
-std::string CuttlefishConfig::InstanceSpecific::device_title() const {
- return (*Dictionary())[kDeviceTitle].asString();
+static constexpr char kQemuVncServerPort[] = "qemu_vnc_server_port";
+int CuttlefishConfig::InstanceSpecific::qemu_vnc_server_port() const {
+ return (*Dictionary())[kQemuVncServerPort].asInt();
}
-void CuttlefishConfig::MutableInstanceSpecific::set_device_title(
- const std::string& title) {
- (*Dictionary())[kDeviceTitle] = title;
-}
-
-static constexpr char kVncServerPort[] = "vnc_server_port";
-int CuttlefishConfig::InstanceSpecific::vnc_server_port() const {
- return (*Dictionary())[kVncServerPort].asInt();
-}
-void CuttlefishConfig::MutableInstanceSpecific::set_vnc_server_port(int vnc_server_port) {
- (*Dictionary())[kVncServerPort] = vnc_server_port;
+void CuttlefishConfig::MutableInstanceSpecific::set_qemu_vnc_server_port(
+ int qemu_vnc_server_port) {
+ (*Dictionary())[kQemuVncServerPort] = qemu_vnc_server_port;
}
static constexpr char kTouchServerPort[] = "touch_server_port";
diff --git a/host/libs/config/known_paths.cpp b/host/libs/config/known_paths.cpp
index 8cf96ed..d92afdd 100644
--- a/host/libs/config/known_paths.cpp
+++ b/host/libs/config/known_paths.cpp
@@ -69,8 +69,6 @@
"android.hardware.automotive.vehicle@2.0-virtualization-grpc-server");
}
-std::string VncServerBinary() { return HostBinaryPath("vnc_server"); }
-
std::string WebRtcBinary() {
return HostBinaryPath("webRTC");
}
diff --git a/host/libs/config/known_paths.h b/host/libs/config/known_paths.h
index cdf93f9..b32b7dd 100644
--- a/host/libs/config/known_paths.h
+++ b/host/libs/config/known_paths.h
@@ -31,7 +31,6 @@
std::string SocketVsockProxyBinary();
std::string TombstoneReceiverBinary();
std::string VehicleHalGrpcServerBinary();
-std::string VncServerBinary();
std::string WebRtcBinary();
std::string WebRtcSigServerBinary();
std::string WmediumdBinary();
diff --git a/host/libs/confui/host_mode_ctrl.h b/host/libs/confui/host_mode_ctrl.h
index 0950971..bf8b575 100644
--- a/host/libs/confui/host_mode_ctrl.h
+++ b/host/libs/confui/host_mode_ctrl.h
@@ -30,7 +30,7 @@
* mechanism to orchestrate concurrent executions of threads
* that work for screen connector
*
- * Within VNC or WebRTC service, it tells when it is now in the Android Mode or
+ * Within WebRTC service, it tells when it is now in the Android Mode or
* Confirmation UI mode
*/
class HostModeCtrl {
diff --git a/host/libs/confui/host_server.cc b/host/libs/confui/host_server.cc
index ff07279..97e80f4 100644
--- a/host/libs/confui/host_server.cc
+++ b/host/libs/confui/host_server.cc
@@ -162,7 +162,7 @@
[[noreturn]] void HostServer::MainLoop() {
while (true) {
// this gets one input from either queue:
- // from HAL or from all webrtc/vnc clients
+ // from HAL or from all webrtc clients
// if no input, sleep until there is
auto input_ptr = input_multiplexer_.Pop();
auto& input = *input_ptr;
diff --git a/host/libs/confui/host_server.h b/host/libs/confui/host_server.h
index 51686e3..904af33 100644
--- a/host/libs/confui/host_server.h
+++ b/host/libs/confui/host_server.h
@@ -51,7 +51,7 @@
void Start(); // start this server itself
virtual ~HostServer() {}
- // implement input interfaces. called by webRTC & vnc
+ // implement input interfaces. called by webRTC
void TouchEvent(const int x, const int y, const bool is_down) override;
void UserAbortEvent() override;
bool IsConfUiActive() override;
@@ -88,7 +88,7 @@
* should render the Android guest frames but keep the confirmation
* UI session and frame
*
- * The inputs are I = {u, g}. 'u' is the user input from vnc/webRTC
+ * The inputs are I = {u, g}. 'u' is the user input from webRTC
* clients. Note that the host service serialized the concurrent user
* inputs from multiple clients. 'g' is the command from the HAL service
*
diff --git a/host/libs/confui/host_virtual_input.h b/host/libs/confui/host_virtual_input.h
index 025af26..65ec577 100644
--- a/host/libs/confui/host_virtual_input.h
+++ b/host/libs/confui/host_virtual_input.h
@@ -23,7 +23,7 @@
enum class ConfUiKeys : std::uint32_t { Confirm = 7, Cancel = 8 };
/**
- * vnc, webrtc will deliver the user inputs from their client
+ * webrtc will deliver the user inputs from their client
* to this class object
*/
class HostVirtualInput {
diff --git a/host/libs/confui/session.cc b/host/libs/confui/session.cc
index 9760cd6..d12af9f 100644
--- a/host/libs/confui/session.cc
+++ b/host/libs/confui/session.cc
@@ -211,7 +211,7 @@
if (!RenderDialog()) {
// the confirmation UI is driven by a user app, not running from the start
- // automatically so that means webRTC/vnc should have been set up
+ // automatically so that means webRTC should have been set up
ConfUiLog(ERROR) << "Dialog is not rendered. However, it should."
<< "No webRTC can't initiate any confirmation UI.";
ReportErrorToHal(hal_cli, HostError::kUIError);
diff --git a/host/libs/confui/session.h b/host/libs/confui/session.h
index d36f7fe..1afccac 100644
--- a/host/libs/confui/session.h
+++ b/host/libs/confui/session.h
@@ -93,7 +93,7 @@
return fsm_input == FsmInput::kUserEvent;
}
- /** create a frame, and render it on the vnc/webRTC client
+ /** create a frame, and render it on the webRTC client
*
* note that this does not check host_ctrl_mode_
*/
@@ -137,7 +137,7 @@
std::unique_ptr<Cbor> cbor_;
- // effectively, this variables are shared with vnc, webRTC thread
+ // effectively, this variables are shared with webRTC thread
// the input demuxer will check the confirmation UI mode based on this
std::atomic<MainLoopState> state_;
MainLoopState saved_state_; // for restore/suspend
diff --git a/host/libs/screen_connector/screen_connector.h b/host/libs/screen_connector/screen_connector.h
index 4a27fda..49e5253 100644
--- a/host/libs/screen_connector/screen_connector.h
+++ b/host/libs/screen_connector/screen_connector.h
@@ -52,11 +52,11 @@
using FrameMultiplexer = ScreenConnectorInputMultiplexer<ProcessedFrameType>;
/**
- * This is the type of the callback function WebRTC/VNC is supposed to provide
+ * This is the type of the callback function WebRTC is supposed to provide
* ScreenConnector with.
*
* The callback function is how a raw bytes frame should be processed for
- * WebRTC/VNC
+ * WebRTC
*
*/
using GenerateProcessedFrameCallback = std::function<void(
diff --git a/host/libs/screen_connector/screen_connector_queue.h b/host/libs/screen_connector/screen_connector_queue.h
index 7643800..66fd7f7 100644
--- a/host/libs/screen_connector/screen_connector_queue.h
+++ b/host/libs/screen_connector/screen_connector_queue.h
@@ -62,14 +62,14 @@
* Note: this queue is supposed to be used only by ScreenConnector-
* related components such as ScreenConnectorSource
*
- * The traditional assumption was that when webRTC or VNC calls
+ * The traditional assumption was that when webRTC calls
* OnFrameAfter, the call should be block until it could return
* one frame.
*
* Thus, the producers of this queue must not produce frames
- * much faster than the consumer, VNC or WebRTC consumes.
+ * much faster than the consumer, WebRTC consumes.
* Therefore, when the small buffer is full -- which means
- * VNC or WebRTC would not call OnFrameAfter --, the producer
+ * WebRTC would not call OnNextFrame --, the producer
* should stop adding itmes to the queue.
*
*/
diff --git a/host/libs/vm_manager/crosvm_manager.cpp b/host/libs/vm_manager/crosvm_manager.cpp
index d7e3dd4..f72e018 100644
--- a/host/libs/vm_manager/crosvm_manager.cpp
+++ b/host/libs/vm_manager/crosvm_manager.cpp
@@ -171,7 +171,7 @@
config.protected_vm() ? "--disk=" : "--rwdisk=", disk);
}
- if (config.enable_vnc_server() || config.enable_webrtc()) {
+ if (config.enable_webrtc()) {
auto touch_type_parameter =
config.enable_webrtc() ? "--multi-touch=" : "--single-touch=";
diff --git a/host/libs/vm_manager/qemu_manager.cpp b/host/libs/vm_manager/qemu_manager.cpp
index c0a96ef..4751234 100644
--- a/host/libs/vm_manager/qemu_manager.cpp
+++ b/host/libs/vm_manager/qemu_manager.cpp
@@ -391,7 +391,7 @@
qemu_cmd.AddParameter("egl-headless");
qemu_cmd.AddParameter("-vnc");
- qemu_cmd.AddParameter(":", instance.vnc_server_port() - 5900);
+ qemu_cmd.AddParameter(":", instance.qemu_vnc_server_port());
} else {
qemu_cmd.AddParameter("-display");
qemu_cmd.AddParameter("none");
diff --git a/shared/BoardConfig.mk b/shared/BoardConfig.mk
index ed0e413..ca518b4 100644
--- a/shared/BoardConfig.mk
+++ b/shared/BoardConfig.mk
@@ -66,19 +66,21 @@
BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_COPY_OUT_ODM_DLKM := odm_dlkm
-# FIXME: Remove this once we generate the vbmeta digest correctly
-BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flag 2
+# Enable AVB
+BOARD_AVB_ENABLE := true
+BOARD_AVB_ALGORITHM := SHA256_RSA4096
+BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
# Enable chained vbmeta for system image mixing
BOARD_AVB_VBMETA_SYSTEM := product system system_ext
-BOARD_AVB_VBMETA_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
-BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA2048
+BOARD_AVB_VBMETA_SYSTEM_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
+BOARD_AVB_VBMETA_SYSTEM_ALGORITHM := SHA256_RSA4096
BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION := 1
# Enable chained vbmeta for boot images
-BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
-BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA2048
+BOARD_AVB_BOOT_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
+BOARD_AVB_BOOT_ALGORITHM := SHA256_RSA4096
BOARD_AVB_BOOT_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION := 2
diff --git a/shared/config/fstab-erofs.ext4 b/shared/config/fstab-erofs.ext4
index ec7b3fe..b296b7a 100644
--- a/shared/config/fstab-erofs.ext4
+++ b/shared/config/fstab-erofs.ext4
@@ -1,6 +1,6 @@
-/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect
+/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=boot
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults recoveryonly,slotselect
-system /system erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
+system /system erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
# Add all non-dynamic partitions except system, after this comment
/dev/block/by-name/userdata /data ext4 nodev,noatime,nosuid,errors=panic latemount,wait,check,quota,formattable,fileencryption=aes-256-xts:aes-256-cts,keydirectory=/metadata/vold/metadata_encryption,checkpoint=block
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,errors=panic wait,formattable,first_stage_mount,check
diff --git a/shared/config/fstab-erofs.f2fs b/shared/config/fstab-erofs.f2fs
index 1b5486e..79f0f4f 100644
--- a/shared/config/fstab-erofs.f2fs
+++ b/shared/config/fstab-erofs.f2fs
@@ -1,6 +1,6 @@
-/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect
+/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=boot
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults recoveryonly,slotselect
-system /system erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
+system /system erofs ro wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
# Add all non-dynamic partitions except system, after this comment
/dev/block/by-name/userdata /data f2fs nodev,noatime,nosuid,inlinecrypt,reserve_root=32768 latemount,wait,check,quota,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,fscompress,keydirectory=/metadata/vold/metadata_encryption,checkpoint=fs
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,errors=panic wait,formattable,first_stage_mount,check
diff --git a/shared/config/fstab.ext4 b/shared/config/fstab.ext4
index 1677941..e6dd2c0 100644
--- a/shared/config/fstab.ext4
+++ b/shared/config/fstab.ext4
@@ -1,6 +1,6 @@
-/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect
+/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=boot
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults recoveryonly,slotselect
-system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
+system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
# Add all non-dynamic partitions except system, after this comment
/dev/block/by-name/userdata /data ext4 nodev,noatime,nosuid,errors=panic latemount,wait,check,quota,formattable,fileencryption=aes-256-xts:aes-256-cts,keydirectory=/metadata/vold/metadata_encryption,checkpoint=block
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,errors=panic wait,formattable,first_stage_mount,check
diff --git a/shared/config/fstab.f2fs b/shared/config/fstab.f2fs
index 597e3f0..301c203 100644
--- a/shared/config/fstab.f2fs
+++ b/shared/config/fstab.f2fs
@@ -1,6 +1,6 @@
-/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect
+/dev/block/by-name/boot /boot emmc defaults recoveryonly,slotselect,first_stage_mount,avb=boot
/dev/block/by-name/vendor_boot /vendor_boot emmc defaults recoveryonly,slotselect
-system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
+system /system ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system,avb_keys=/avb
# Add all non-dynamic partitions except system, after this comment
/dev/block/by-name/userdata /data f2fs nodev,noatime,nosuid,inlinecrypt,reserve_root=32768 latemount,wait,check,quota,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,fscompress,keydirectory=/metadata/vold/metadata_encryption,checkpoint=fs
/dev/block/by-name/metadata /metadata ext4 nodev,noatime,nosuid,errors=panic wait,formattable,first_stage_mount,check
diff --git a/shared/config/init.vendor.rc b/shared/config/init.vendor.rc
index 8ac3baf..731637d 100644
--- a/shared/config/init.vendor.rc
+++ b/shared/config/init.vendor.rc
@@ -54,8 +54,6 @@
# set RLIMIT_MEMLOCK to 64MB
setrlimit 8 67108864 67108864
- start bt_vhci_forwarder
-
on post-fs-data
# works around framework netiface enumeration issue
# TODO(b/202731768): Add this `start rename_eth0` command to the init.rc for rename_netiface
@@ -88,6 +86,9 @@
setprop ro.hardware.audio.primary goldfish
symlink /dev/hvc6 /dev/gnss0
+ # Update dm-verity state and set partition.*.verified properties
+ verity_update_state
+
service wifi-net-sh /vendor/bin/init.wifi.sh
class late_start
user root
@@ -95,10 +96,6 @@
oneshot
disabled # Started on post-fs-data
-service bt_vhci_forwarder /vendor/bin/bt_vhci_forwarder -virtio_console_dev=${vendor.ser.bt-uart}
- user bluetooth
- group bluetooth
-
on property:sys.boot_completed=1
trigger sys-boot-completed-set
diff --git a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_0.idc b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_0.idc
index 8a03307..b6d8c78 100644
--- a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_0.idc
+++ b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_0.idc
@@ -3,4 +3,4 @@
touch.deviceType = touchScreen
touch.orientationAware = 1
-# touch.displayId = local:8141241408256768
+# touch.displayId = local:4619827259835644672
diff --git a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_1.idc b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_1.idc
index 1e57818..a375e58 100644
--- a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_1.idc
+++ b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_1.idc
@@ -3,4 +3,4 @@
touch.deviceType = touchScreen
touch.orientationAware = 1
-touch.displayId = local:8141533520759297
+touch.displayId = local:4619827551948147201
diff --git a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_2.idc b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_2.idc
index c9d6a8f..db17d3c 100644
--- a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_2.idc
+++ b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_2.idc
@@ -3,4 +3,4 @@
touch.deviceType = touchScreen
touch.orientationAware = 1
-touch.displayId = local:8141106354454786
+touch.displayId = local:4619827124781842690
diff --git a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_3.idc b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_3.idc
index a133e24..b910ad3 100644
--- a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_3.idc
+++ b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_3.idc
@@ -3,4 +3,4 @@
touch.deviceType = touchScreen
touch.orientationAware = 1
-touch.displayId = local:8141521668171267
+touch.displayId = local:4619827540095559171
diff --git a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_4.idc b/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_4.idc
deleted file mode 100644
index c32fb3c..0000000
--- a/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_4.idc
+++ /dev/null
@@ -1,6 +0,0 @@
-device.internal = 1
-
-touch.deviceType = touchScreen
-touch.orientationAware = 1
-
-touch.displayId = local:8141140893513220
diff --git a/shared/device.mk b/shared/device.mk
index e21cd4f..bf9fc63 100644
--- a/shared/device.mk
+++ b/shared/device.mk
@@ -244,7 +244,14 @@
hidl_lazy_test_server \
hidl_lazy_cb_test_server
-DEVICE_PACKAGE_OVERLAYS := device/google/cuttlefish/shared/overlay
+# Runtime Resource Overlays
+ifneq ($(LOCAL_PREFER_VENDOR_APEX),true)
+PRODUCT_PACKAGES += \
+ cuttlefish_overlay_frameworks_base_core \
+ cuttlefish_overlay_settings_provider \
+
+endif
+
# PRODUCT_AAPT_CONFIG and PRODUCT_AAPT_PREF_CONFIG are intentionally not set to
# pick up every density resources.
@@ -312,13 +319,11 @@
frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \
frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \
frameworks/av/services/audiopolicy/config/surround_sound_configuration_5_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/surround_sound_configuration_5_0.xml \
- system/bt/vendor_libs/test_vendor_lib/data/controller_properties.json:vendor/etc/bluetooth/controller_properties.json \
device/google/cuttlefish/shared/config/task_profiles.json:$(TARGET_COPY_OUT_VENDOR)/etc/task_profiles.json \
device/google/cuttlefish/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_0.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/Crosvm_Virtio_Multitouch_Touchscreen_0.idc \
device/google/cuttlefish/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_1.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/Crosvm_Virtio_Multitouch_Touchscreen_1.idc \
device/google/cuttlefish/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_2.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/Crosvm_Virtio_Multitouch_Touchscreen_2.idc \
- device/google/cuttlefish/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_3.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/Crosvm_Virtio_Multitouch_Touchscreen_3.idc \
- device/google/cuttlefish/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_4.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/Crosvm_Virtio_Multitouch_Touchscreen_4.idc
+ device/google/cuttlefish/shared/config/input/Crosvm_Virtio_Multitouch_Touchscreen_3.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/Crosvm_Virtio_Multitouch_Touchscreen_3.idc
ifeq ($(TARGET_RO_FILE_SYSTEM_TYPE),ext4)
PRODUCT_COPY_FILES += \
@@ -415,6 +420,12 @@
PRODUCT_PACKAGES += android.hardware.bluetooth.audio@2.1-impl
+# Bluetooth initialization configuration is copied to the init folder here instead of being added
+# as an init_rc attribute of the bt_vhci_forward binary. The bt_vhci_forward binary is used by
+# multiple targets with different initialization configurations.
+PRODUCT_COPY_FILES += \
+ device/google/cuttlefish/guest/commands/bt_vhci_forwarder/bt_vhci_forwarder.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/bt_vhci_forwarder.rc
+
#
# Audio HAL
#
@@ -477,8 +488,10 @@
#
# Confirmation UI HAL
#
-PRODUCT_PACKAGES += \
- android.hardware.confirmationui@1.0-service.cuttlefish
+ifeq ($(LOCAL_CONFIRMATIONUI_PRODUCT_PACKAGE),)
+ LOCAL_CONFIRMATIONUI_PRODUCT_PACKAGE := android.hardware.confirmationui@1.0-service.cuttlefish
+endif
+PRODUCT_PACKAGES += $(LOCAL_CONFIRMATIONUI_PRODUCT_PACKAGE)
#
# Dumpstate HAL
diff --git a/shared/overlays/SettingsProvider/Android.bp b/shared/overlays/SettingsProvider/Android.bp
new file mode 100644
index 0000000..e6aacb1
--- /dev/null
+++ b/shared/overlays/SettingsProvider/Android.bp
@@ -0,0 +1,4 @@
+runtime_resource_overlay {
+ name: "cuttlefish_overlay_settings_provider",
+ soc_specific: true,
+}
diff --git a/shared/overlays/SettingsProvider/AndroidManifest.xml b/shared/overlays/SettingsProvider/AndroidManifest.xml
new file mode 100644
index 0000000..74656f1
--- /dev/null
+++ b/shared/overlays/SettingsProvider/AndroidManifest.xml
@@ -0,0 +1,10 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.providers.settings.cuttlefish.overlay">
+
+ <application android:hasCode="false" />
+
+ <overlay
+ android:targetPackage="com.android.providers.settings"
+ android:isStatic="true"
+ />
+</manifest>
diff --git a/shared/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/shared/overlays/SettingsProvider/res/values/defaults.xml
similarity index 100%
rename from shared/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
rename to shared/overlays/SettingsProvider/res/values/defaults.xml
diff --git a/shared/overlays/core/Android.bp b/shared/overlays/core/Android.bp
new file mode 100644
index 0000000..47bbbc6
--- /dev/null
+++ b/shared/overlays/core/Android.bp
@@ -0,0 +1,4 @@
+runtime_resource_overlay {
+ name: "cuttlefish_overlay_frameworks_base_core",
+ soc_specific: true,
+}
diff --git a/shared/overlays/core/AndroidManifest.xml b/shared/overlays/core/AndroidManifest.xml
new file mode 100644
index 0000000..284ab6b
--- /dev/null
+++ b/shared/overlays/core/AndroidManifest.xml
@@ -0,0 +1,10 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.cuttlefish.overlay">
+
+ <application android:hasCode="false" />
+
+ <overlay
+ android:targetPackage="android"
+ android:isStatic="true"
+ />
+</manifest>
diff --git a/shared/overlay/frameworks/base/core/res/res/xml/power_profile.xml b/shared/overlays/core/res/xml/power_profile.xml
similarity index 100%
rename from shared/overlay/frameworks/base/core/res/res/xml/power_profile.xml
rename to shared/overlays/core/res/xml/power_profile.xml
diff --git a/shared/phone/device.mk b/shared/phone/device.mk
index faa2c7c..b87aedc 100644
--- a/shared/phone/device.mk
+++ b/shared/phone/device.mk
@@ -32,9 +32,14 @@
Phone \
PhoneService \
Telecom \
- TeleService \
+ TeleService
+
+TARGET_USES_CF_RILD ?= true
+ifeq ($(TARGET_USES_CF_RILD),true)
+PRODUCT_PACKAGES += \
libcuttlefish-ril-2 \
libcuttlefish-rild
+endif
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.faketouch.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.faketouch.xml \
diff --git a/shared/phone/device_vendor.mk b/shared/phone/device_vendor.mk
index 7c2e1af..2f5fda0 100644
--- a/shared/phone/device_vendor.mk
+++ b/shared/phone/device_vendor.mk
@@ -35,6 +35,8 @@
ro.com.android.dataroaming=true \
ro.telephony.default_network=9 \
+TARGET_USES_CF_RILD ?= true
+ifeq ($(TARGET_USES_CF_RILD),true)
ifeq ($(LOCAL_PREFER_VENDOR_APEX),true)
PRODUCT_PACKAGES += com.google.cf.rild
else
@@ -42,6 +44,7 @@
libcuttlefish-ril-2 \
libcuttlefish-rild
endif
+endif
ifneq ($(LOCAL_PREFER_VENDOR_APEX),true)
PRODUCT_COPY_FILES += \
@@ -52,6 +55,11 @@
frameworks/native/data/etc/android.hardware.telephony.ims.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.telephony.ims.xml
endif
-DEVICE_PACKAGE_OVERLAYS += device/google/cuttlefish/shared/phone/overlay
+# Runtime Resource Overlays
+ifeq ($(LOCAL_PREFER_VENDOR_APEX),true)
+PRODUCT_PACKAGES += com.google.aosp_cf_x86_64_phone.rros
+else
+PRODUCT_PACKAGES += cuttlefish_phone_overlay_frameworks_base_core
+endif
TARGET_BOARD_INFO_FILE ?= device/google/cuttlefish/shared/phone/android-info.txt
diff --git a/shared/phone/overlays/core/Android.bp b/shared/phone/overlays/core/Android.bp
new file mode 100644
index 0000000..6a926b4
--- /dev/null
+++ b/shared/phone/overlays/core/Android.bp
@@ -0,0 +1,4 @@
+runtime_resource_overlay {
+ name: "cuttlefish_phone_overlay_frameworks_base_core",
+ soc_specific: true,
+}
diff --git a/shared/phone/overlays/core/AndroidManifest.xml b/shared/phone/overlays/core/AndroidManifest.xml
new file mode 100644
index 0000000..268a8bc
--- /dev/null
+++ b/shared/phone/overlays/core/AndroidManifest.xml
@@ -0,0 +1,10 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.cuttlefish.phone.overlay">
+
+ <application android:hasCode="false" />
+
+ <overlay
+ android:targetPackage="android"
+ android:isStatic="true"
+ />
+</manifest>
diff --git a/shared/phone/overlay/frameworks/base/core/res/res/values/config.xml b/shared/phone/overlays/core/res/values/config.xml
similarity index 100%
rename from shared/phone/overlay/frameworks/base/core/res/res/values/config.xml
rename to shared/phone/overlays/core/res/values/config.xml
diff --git a/shared/sepolicy/vendor/device.te b/shared/sepolicy/vendor/device.te
index fe42c1f..b698e35 100644
--- a/shared/sepolicy/vendor/device.te
+++ b/shared/sepolicy/vendor/device.te
@@ -1,2 +1,2 @@
# Device types
-type ab_block_device, dev_type, bdev_type;
+type ab_block_device, dev_type;
diff --git a/shared/sepolicy/vendor/hal_confirmationui_cuttlefish.te b/shared/sepolicy/vendor/hal_confirmationui_cuttlefish.te
index 501bcfa..13cd1a9 100644
--- a/shared/sepolicy/vendor/hal_confirmationui_cuttlefish.te
+++ b/shared/sepolicy/vendor/hal_confirmationui_cuttlefish.te
@@ -7,7 +7,7 @@
vendor_internal_prop(vendor_vsock_confirmationui_port_prop)
get_prop(hal_confirmationui_cuttlefish, vendor_vsock_confirmationui_port_prop)
-allow hal_confirmationui_cuttlefish self:{ vsock_socket } { create getopt read write connect shutdown };
+allow hal_confirmationui_cuttlefish self:{ vsock_socket } { create getopt read write getattr connect shutdown };
# Write to kernel log (/dev/kmsg)
allow hal_confirmationui_cuttlefish kmsg_device:chr_file w_file_perms;
diff --git a/shared/sepolicy/vendor/init.te b/shared/sepolicy/vendor/init.te
index 7f362ef..8676c60 100644
--- a/shared/sepolicy/vendor/init.te
+++ b/shared/sepolicy/vendor/init.te
@@ -12,8 +12,9 @@
allow init binfmt_miscfs:file w_file_perms;
allow init proc:dir mounton;
-# init relabel vbmeta* symlinks
+# init relabel vbmeta* and boot* symlinks under /dev/block/by-name/.
allow init ab_block_device:lnk_file relabelto;
+allow init boot_block_device:lnk_file relabelto;
# /mnt/sdcard -> /storage/self/primary symlink is deprecated. Ignore attempts to
# create it. This denial is fixed in core policy in Android R aosp/943799.
diff --git a/shared/sepolicy/vendor/libcuttlefish_rild.te b/shared/sepolicy/vendor/libcuttlefish_rild.te
index 8f3bbe7..28412c7 100644
--- a/shared/sepolicy/vendor/libcuttlefish_rild.te
+++ b/shared/sepolicy/vendor/libcuttlefish_rild.te
@@ -11,4 +11,4 @@
get_prop(libcuttlefish_rild, vendor_cuttlefish_config_server_port_prop)
get_prop(libcuttlefish_rild, vendor_modem_simulator_ports_prop)
-allow libcuttlefish_rild self:{ socket vsock_socket } create_socket_perms_no_ioctl;
+allow libcuttlefish_rild self:{ socket vsock_socket } { create_socket_perms_no_ioctl getattr };
diff --git a/shared/sepolicy/vendor/rename_netiface.te b/shared/sepolicy/vendor/rename_netiface.te
index 1ec0f06..f648a7e 100644
--- a/shared/sepolicy/vendor/rename_netiface.te
+++ b/shared/sepolicy/vendor/rename_netiface.te
@@ -5,6 +5,6 @@
allow rename_netiface self:capability { net_admin net_raw sys_module };
allow rename_netiface self:udp_socket { create ioctl };
-allow rename_netiface self:netlink_route_socket { bind create nlmsg_write read write };
+allow rename_netiface self:netlink_route_socket { bind create nlmsg_write read write getattr };
allow rename_netiface kernel:system module_request;
diff --git a/shared/sepolicy/vendor/setup_wifi.te b/shared/sepolicy/vendor/setup_wifi.te
index b61d4be..6a8d054 100644
--- a/shared/sepolicy/vendor/setup_wifi.te
+++ b/shared/sepolicy/vendor/setup_wifi.te
@@ -5,7 +5,7 @@
allow setup_wifi self:capability { net_admin net_raw sys_module };
allow setup_wifi self:udp_socket { create ioctl };
-allow setup_wifi self:netlink_route_socket { bind create nlmsg_write read write };
+allow setup_wifi self:netlink_route_socket { bind create nlmsg_write read write getattr };
allow setup_wifi kernel:system module_request;
diff --git a/shared/sepolicy/vendor/socket_vsock_proxy.te b/shared/sepolicy/vendor/socket_vsock_proxy.te
index d4e2b1a..6f72963 100644
--- a/shared/sepolicy/vendor/socket_vsock_proxy.te
+++ b/shared/sepolicy/vendor/socket_vsock_proxy.te
@@ -4,7 +4,7 @@
init_daemon_domain(socket_vsock_proxy)
allow socket_vsock_proxy self:global_capability_class_set { net_admin net_raw };
-allow socket_vsock_proxy self:{ socket vsock_socket } { create getopt read write listen accept bind shutdown };
+allow socket_vsock_proxy self:{ socket vsock_socket } { create getopt read write getattr listen accept bind shutdown };
# TODO: socket returned by accept() has unlabeled context on it. Give it a
# specific label.
diff --git a/tests/hal/hal_implementation_test.cpp b/tests/hal/hal_implementation_test.cpp
index 53bf097..cf05ed5 100644
--- a/tests/hal/hal_implementation_test.cpp
+++ b/tests/hal/hal_implementation_test.cpp
@@ -137,6 +137,9 @@
// This version needs to be implemented (b/190505425)
{"android.system.keystore2.", 2},
+ // This version needs to be implemented (b/177269435)
+ {"android.hardware.health.", 1},
+
// These versions need to be implemented (b/198331776)
{"android.hardware.radio.", 1},
{"android.hardware.radio.data.", 1},