Line number of modifier keys is relying on the height of keys' view

Bug: 401539885
Test: Running VmTerminalApp in foldable device
Change-Id: I0706e890a6404532cb75a9442f8960c7e6fbf767
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt b/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt
index ed340d2..7c3eb69 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt
@@ -115,10 +115,12 @@
             activeTerminalView!!.hasFocus() &&
             !(activity.resources.configuration.keyboard == Configuration.KEYBOARD_QWERTY)
 
-    // If terminal's height is less than 30% of the screen height, we need to show modifier keys in
-    // a single line to save the vertical space
-    private fun needsKeysInSingleLine(): Boolean =
-        activeTerminalView!!.height.div(activity.window.decorView.height.toFloat()) < 0.3f
+    // If terminal's height including height of modifier keys is less than 40% of the screen
+    // height, we need to show modifier keys in a single line to save the vertical space
+    private fun needsKeysInSingleLine(): Boolean {
+        val keys = if (keysInSingleLine) keysSingleLine else keysDoubleLine
+        return activeTerminalView!!.height + keys.height < 0.4f * activity.window.decorView.height
+    }
 
     companion object {
         private val BTN_KEY_CODE_MAP =