Merge "Ignore implicit -c before -E" into main
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.kt b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.kt
index 71f10f9..1daeadb 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/MainActivity.kt
@@ -35,12 +35,14 @@
import android.os.SystemProperties
import android.os.Trace
import android.provider.Settings
+import android.util.DisplayMetrics
import android.util.Log
import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
+import android.view.WindowManager
import android.view.accessibility.AccessibilityManager
import android.webkit.ClientCertRequest
import android.webkit.SslErrorHandler
@@ -457,7 +459,7 @@
.build()
Trace.beginAsyncSection("executeTerminal", 0)
- run(this, this, notification)
+ run(this, this, notification, getDisplayInfo())
connectToTerminalService()
}
@@ -511,4 +513,18 @@
R.id.btn_pgdn to KeyEvent.KEYCODE_PAGE_DOWN,
)
}
+
+ fun getDisplayInfo(): DisplayInfo {
+ val wm = getSystemService<WindowManager>(WindowManager::class.java)
+ val metrics = wm.currentWindowMetrics
+ val dispBounds = metrics.bounds
+
+ // For now, display activity runs as landscape mode
+ val height = Math.min(dispBounds.right, dispBounds.bottom)
+ val width = Math.max(dispBounds.right, dispBounds.bottom)
+ var dpi = (DisplayMetrics.DENSITY_DEFAULT * metrics.density).toInt()
+ var refreshRate = display.refreshRate.toInt()
+
+ return DisplayInfo(width, height, dpi, refreshRate)
+ }
}
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt b/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt
index 346056a..ecb01c0 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt
@@ -29,6 +29,7 @@
import android.os.IBinder
import android.os.Looper
import android.os.Parcel
+import android.os.Parcelable
import android.os.ResultReceiver
import android.os.Trace
import android.system.virtualmachine.VirtualMachine
@@ -103,7 +104,8 @@
val json = ConfigJson.from(this, image.configPath)
val configBuilder = json.toConfigBuilder(this)
val customImageConfigBuilder = json.toCustomImageConfigBuilder(this)
- if (overrideConfigIfNecessary(customImageConfigBuilder)) {
+ val displaySize = intent.getParcelableExtra(EXTRA_DISPLAY_INFO, DisplayInfo::class.java)
+ if (overrideConfigIfNecessary(customImageConfigBuilder, displaySize)) {
configBuilder.setCustomImageConfig(customImageConfigBuilder.build())
}
val config = configBuilder.build()
@@ -198,7 +200,8 @@
}
private fun overrideConfigIfNecessary(
- builder: VirtualMachineCustomImageConfig.Builder
+ builder: VirtualMachineCustomImageConfig.Builder,
+ displayInfo: DisplayInfo?,
): Boolean {
var changed = false
// TODO: check if ANGLE is enabled for the app.
@@ -218,13 +221,17 @@
changed = true
}
- // TODO(jeongik): let it configurable
- if (terminalGuiSupport()) {
+ // Set the initial display size
+ // TODO(jeongik): set up the display size on demand
+ if (terminalGuiSupport() && displayInfo != null) {
builder
.setDisplayConfig(
VirtualMachineCustomImageConfig.DisplayConfig.Builder()
- .setWidth(1920)
- .setHeight(1080)
+ .setWidth(displayInfo.width)
+ .setHeight(displayInfo.height)
+ .setHorizontalDpi(displayInfo.dpi)
+ .setVerticalDpi(displayInfo.dpi)
+ .setRefreshRate(displayInfo.refreshRate)
.build()
)
.useKeyboard(true)
@@ -322,7 +329,7 @@
private const val EXTRA_NOTIFICATION = "EXTRA_NOTIFICATION"
private const val ACTION_START_VM_LAUNCHER_SERVICE =
"android.virtualization.START_VM_LAUNCHER_SERVICE"
-
+ const val EXTRA_DISPLAY_INFO = "EXTRA_DISPLAY_INFO"
const val ACTION_STOP_VM_LAUNCHER_SERVICE: String =
"android.virtualization.STOP_VM_LAUNCHER_SERVICE"
@@ -338,6 +345,7 @@
context: Context,
callback: VmLauncherServiceCallback?,
notification: Notification?,
+ displayInfo: DisplayInfo,
) {
val i = getMyIntent(context)
val resultReceiver: ResultReceiver =
@@ -355,6 +363,7 @@
}
i.putExtra(Intent.EXTRA_RESULT_RECEIVER, getResultReceiverForIntent(resultReceiver))
i.putExtra(EXTRA_NOTIFICATION, notification)
+ i.putExtra(EXTRA_DISPLAY_INFO, displayInfo)
context.startForegroundService(i)
}
@@ -372,3 +381,29 @@
}
}
}
+
+data class DisplayInfo(val width: Int, val height: Int, val dpi: Int, val refreshRate: Int) :
+ Parcelable {
+ constructor(
+ source: Parcel
+ ) : this(source.readInt(), source.readInt(), source.readInt(), source.readInt())
+
+ override fun describeContents(): Int = 0
+
+ override fun writeToParcel(dest: Parcel, flags: Int) {
+ dest.writeInt(width)
+ dest.writeInt(height)
+ dest.writeInt(dpi)
+ dest.writeInt(refreshRate)
+ }
+
+ companion object {
+ @JvmField
+ val CREATOR =
+ object : Parcelable.Creator<DisplayInfo> {
+ override fun createFromParcel(source: Parcel): DisplayInfo = DisplayInfo(source)
+
+ override fun newArray(size: Int) = arrayOfNulls<DisplayInfo>(size)
+ }
+ }
+}
diff --git a/android/TerminalApp/res/layout/activity_display.xml b/android/TerminalApp/res/layout/activity_display.xml
index 48e49fe..2d7d847 100644
--- a/android/TerminalApp/res/layout/activity_display.xml
+++ b/android/TerminalApp/res/layout/activity_display.xml
@@ -27,8 +27,8 @@
<!-- the size should be match_parent -->
<SurfaceView
android:id="@+id/surface_view"
- android:layout_width="1920px"
- android:layout_height="1080px"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:focusedByDefault="true"
diff --git a/build/debian/build.sh b/build/debian/build.sh
index 1c7dd93..da01695 100755
--- a/build/debian/build.sh
+++ b/build/debian/build.sh
@@ -227,7 +227,11 @@
# NOTE: 6.1 is the latest LTS kernel for which Debian's kernel build scripts
# work on Python 3.10, the default version on our Ubuntu 22.04 builders.
- local debian_kver="6.1.119-1"
+ #
+ # We track the latest Debian stable kernel version for the 6.1 branch,
+ # which can be found at:
+ # https://packages.debian.org/stable/linux-source-6.1
+ local debian_kver="6.1.123-1"
local dsc_file="linux_${debian_kver}.dsc"
local orig_ksrc_file="linux_${debian_kver%-*}.orig.tar.xz"
diff --git a/guest/trusty/security_vm/vm/Android.bp b/guest/trusty/security_vm/vm/Android.bp
index f23385b..ee64095 100644
--- a/guest/trusty/security_vm/vm/Android.bp
+++ b/guest/trusty/security_vm/vm/Android.bp
@@ -12,12 +12,79 @@
src: ":trusty_security_vm_signed",
},
arm64: {
- src: ":trusty_security_vm_signed",
+ src: ":security_vm_elf",
},
},
src: ":empty_file",
}
+cc_binary {
+ name: "security_vm_elf",
+ srcs: [
+ ":security_vm_signed_obj",
+ ],
+ linker_scripts: [
+ "security_vm_sections.ld",
+ ],
+ ldflags: [
+ // Prevent the `trusty_security_vm_signed` segment from being garbage collected.
+ "-Wl,--no-gc-sections",
+ // Prevent the build ID segments from being added, as it would corrupt the integrity
+ // of the original signed image.
+ "-Wl,--build-id=none",
+ // Use a standard page size of 4096, smaller than the default 16384, to avoid padding
+ // with extra bytes.
+ "-Wl,-z,max-page-size=4096",
+ ],
+ nocrt: true,
+ no_libcrt: true,
+ static_executable: true,
+ system_shared_libs: [],
+ enabled: false,
+ target: {
+ android_arm64: {
+ enabled: true,
+ },
+ },
+ strip: {
+ none: true,
+ },
+}
+
+cc_genrule {
+ name: "security_vm.S",
+ arch: {
+ arm64: {
+ srcs: [":trusty_security_vm_signed"],
+ },
+ },
+ out: ["security_vm.S"],
+ cmd: "(" +
+ " echo '.section .security_vm_signed.bin';" +
+ " echo '.globl security_vm_signed';" +
+ " echo 'security_vm_signed:';" +
+ " echo '.incbin \"'$(in)'\"';" +
+ ") > $(out)",
+ visibility: ["//visibility:private"],
+}
+
+cc_object {
+ name: "security_vm_signed_obj",
+ srcs: [
+ ":security_vm.S",
+ ],
+ static_libs: ["trusty_security_vm_signed"],
+ crt: false,
+ system_shared_libs: [],
+ enabled: false,
+ target: {
+ android_arm64: {
+ enabled: true,
+ },
+ },
+ visibility: ["//visibility:private"],
+}
+
filegroup {
name: "trusty_vm_sign_key",
srcs: [":avb_testkey_rsa4096"],
@@ -49,7 +116,20 @@
enabled: true,
},
arm64: {
- src: ":trusty-test-lk.elf",
+ src: ":trusty_security_vm_unsigned",
+ enabled: true,
+ },
+ },
+}
+
+// TODO(b/379646659): Take the binary generated by trusty instead of extracting
+// it from ELF here.
+raw_binary {
+ name: "trusty_security_vm_unsigned",
+ src: ":trusty-test-lk.elf",
+ enabled: false,
+ arch: {
+ arm64: {
enabled: true,
},
},
diff --git a/guest/trusty/security_vm/vm/security_vm_sections.ld b/guest/trusty/security_vm/vm/security_vm_sections.ld
new file mode 100644
index 0000000..63e5f5d
--- /dev/null
+++ b/guest/trusty/security_vm/vm/security_vm_sections.ld
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2025 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
+ *
+ * https://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.
+ */
+
+ENTRY(security_vm_signed)
+
+SECTIONS
+{
+ . = 0x0;
+ .text : {
+ *(.security_vm_signed.bin)
+ }
+}