Merge "Convert ConfigJson to kotlin" into main
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/InstalledImage.kt b/android/TerminalApp/java/com/android/virtualization/terminal/InstalledImage.kt
index f74e0ec..db918fe 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/InstalledImage.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/InstalledImage.kt
@@ -95,13 +95,20 @@
runE2fsck(rootPartition)
val p: String = rootPartition.toAbsolutePath().toString()
val result = runCommand("/system/bin/resize2fs", "-P", p)
- // The return value is the number of 4k block
- return try {
- roundUp(result.lines().first().substring(42).toLong() * 4 * 1024)
- } catch (e: NumberFormatException) {
- Log.e(TAG, "Failed to parse min size, p=$p, result=$result")
- throw IOException(e)
+ val regex = "Estimated minimum size of the filesystem: ([0-9]+)".toRegex()
+ val matchResult = result.lines().firstNotNullOfOrNull { regex.find(it) }
+ if (matchResult != null) {
+ try {
+ val size = matchResult.groupValues[1].toLong()
+ // The return value is the number of 4k block
+ return roundUp(size * 4 * 1024)
+ } catch (e: NumberFormatException) {
+ // cannot happen
+ }
}
+ val msg = "Failed to get min size, p=$p, result=$result"
+ Log.e(TAG, msg)
+ throw RuntimeException(msg)
}
@Throws(IOException::class)
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/InstallerActivity.kt b/android/TerminalApp/java/com/android/virtualization/terminal/InstallerActivity.kt
index 2bd166e..13cd983 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/InstallerActivity.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/InstallerActivity.kt
@@ -130,7 +130,7 @@
}
private fun showSnackBar(message: String, length: Int) {
- val snackBar = Snackbar.make(findViewById<View>(R.id.content), message, length)
+ val snackBar = Snackbar.make(findViewById<View>(android.R.id.content), message, length)
snackBar.anchorView = waitForWifiCheckbox
snackBar.show()
}
diff --git a/android/TerminalApp/res/layout/activity_error.xml b/android/TerminalApp/res/layout/activity_error.xml
index 054478f..c0409a7 100644
--- a/android/TerminalApp/res/layout/activity_error.xml
+++ b/android/TerminalApp/res/layout/activity_error.xml
@@ -51,7 +51,9 @@
android:layout_marginTop="24dp"
android:layout_marginHorizontal="60dp"
android:layout_below="@id/desc"
- android:textSize="14sp" />
+ android:textSize="14sp"
+ android:scrollbars="vertical|horizontal"
+ android:scrollHorizontally="true" />
<Button
android:id="@+id/recovery"