Merge changes I39e5d8f9,I01e89a6b into main
* changes:
Parse resize2fs output correctly
Make error cause text view scrollable
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/InstalledImage.kt b/android/TerminalApp/java/com/android/virtualization/terminal/InstalledImage.kt
index e52f996..c143b17 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/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"