Parse resize2fs output correctly

The output from resize2fs is as follows.

resize2fs 1.46.6 (1-Feb-2023)
Estimated minimum size of the filesystem: 713516

Bug: N/A
Test: run Terminal, go to disk resize settings page
Change-Id: I39e5d8f9033901094461cb2a7d111d6f68ace733
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)