TerminalApp: Run ktfmt

Ran:
$ ./external/ktfmt/ktfmt.sh --kotlinlang-style \
    ./android/TerminalApp/java/com/android/virtualization/terminal/*.k

Bug: none
Test: presubmit

Change-Id: Ia115e9e1c2e2d68951f97c34528ea48c9703eca5
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/Logger.kt b/android/TerminalApp/java/com/android/virtualization/terminal/Logger.kt
index d02491b..4162247 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/Logger.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/Logger.kt
@@ -51,8 +51,7 @@
             deleteOldLogs(dir, 10)
             val logPath = dir.resolve(LocalDateTime.now().toString() + ".txt")
             val console = vm.getConsoleOutput()
-            val file =
-                Files.newOutputStream(logPath, StandardOpenOption.CREATE)
+            val file = Files.newOutputStream(logPath, StandardOpenOption.CREATE)
             executor.submit<Int?> {
                 console.use { console ->
                     LineBufferedOutputStream(file).use { fileOutput ->
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt b/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt
index aa1898f..5f3fd49 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/VmLauncherService.kt
@@ -55,8 +55,8 @@
 import java.io.File
 import java.io.FileOutputStream
 import java.io.IOException
-import java.lang.RuntimeException
 import java.lang.Math.min
+import java.lang.RuntimeException
 import java.net.InetSocketAddress
 import java.net.SocketAddress
 import java.nio.file.Files
@@ -78,39 +78,41 @@
     private var debianService: DebianServiceImpl? = null
     private var portNotifier: PortNotifier? = null
     private var mLock = Object()
-    @GuardedBy("mLock")
-    private var currentMemBalloonPercent = 0;
+    @GuardedBy("mLock") private var currentMemBalloonPercent = 0
 
-    @GuardedBy("mLock")
-    private val inflateMemBalloonHandler = Handler(Looper.getMainLooper())
-    private val inflateMemBalloonTask: Runnable = object : Runnable {
-        override fun run() {
-            synchronized(mLock) {
-                if (currentMemBalloonPercent < INITIAL_MEM_BALLOON_PERCENT
-                    || currentMemBalloonPercent > MAX_MEM_BALLOON_PERCENT
-                ) {
-                    Log.e(
-                        TAG, "currentBalloonPercent=$currentMemBalloonPercent is invalid," +
+    @GuardedBy("mLock") private val inflateMemBalloonHandler = Handler(Looper.getMainLooper())
+    private val inflateMemBalloonTask: Runnable =
+        object : Runnable {
+            override fun run() {
+                synchronized(mLock) {
+                    if (
+                        currentMemBalloonPercent < INITIAL_MEM_BALLOON_PERCENT ||
+                            currentMemBalloonPercent > MAX_MEM_BALLOON_PERCENT
+                    ) {
+                        Log.e(
+                            TAG,
+                            "currentBalloonPercent=$currentMemBalloonPercent is invalid," +
                                 " should be in range: " +
-                                "$INITIAL_MEM_BALLOON_PERCENT~$MAX_MEM_BALLOON_PERCENT"
-                    )
-                    return
-                }
-                // Increases the balloon size by MEM_BALLOON_PERCENT_STEP% every time
-                if (currentMemBalloonPercent < MAX_MEM_BALLOON_PERCENT) {
-                    currentMemBalloonPercent =
-                        min(
-                            MAX_MEM_BALLOON_PERCENT,
-                            currentMemBalloonPercent + MEM_BALLOON_PERCENT_STEP
+                                "$INITIAL_MEM_BALLOON_PERCENT~$MAX_MEM_BALLOON_PERCENT",
                         )
-                    virtualMachine?.setMemoryBalloonByPercent(currentMemBalloonPercent)
-                    inflateMemBalloonHandler.postDelayed(this,
-                        MEM_BALLOON_INFLATE_INTERVAL_MILLIS)
+                        return
+                    }
+                    // Increases the balloon size by MEM_BALLOON_PERCENT_STEP% every time
+                    if (currentMemBalloonPercent < MAX_MEM_BALLOON_PERCENT) {
+                        currentMemBalloonPercent =
+                            min(
+                                MAX_MEM_BALLOON_PERCENT,
+                                currentMemBalloonPercent + MEM_BALLOON_PERCENT_STEP,
+                            )
+                        virtualMachine?.setMemoryBalloonByPercent(currentMemBalloonPercent)
+                        inflateMemBalloonHandler.postDelayed(
+                            this,
+                            MEM_BALLOON_INFLATE_INTERVAL_MILLIS,
+                        )
+                    }
                 }
             }
         }
-    }
-
 
     interface VmLauncherServiceCallback {
         fun onVmStart()
@@ -136,8 +138,8 @@
             // This gives the app maximum available memory.
             ApplicationLifeCycleEvent.APP_ON_START -> {
                 synchronized(mLock) {
-                    inflateMemBalloonHandler.removeCallbacks(inflateMemBalloonTask);
-                    currentMemBalloonPercent = 0;
+                    inflateMemBalloonHandler.removeCallbacks(inflateMemBalloonTask)
+                    currentMemBalloonPercent = 0
                     virtualMachine?.setMemoryBalloonByPercent(currentMemBalloonPercent)
                 }
             }
@@ -148,12 +150,12 @@
                 // MAX_MEM_BALLOON_PERCENT of total memory. This allows the system to reclaim
                 // memory while the app is in the background.
                 synchronized(mLock) {
-                    currentMemBalloonPercent = INITIAL_MEM_BALLOON_PERCENT;
+                    currentMemBalloonPercent = INITIAL_MEM_BALLOON_PERCENT
                     virtualMachine?.setMemoryBalloonByPercent(currentMemBalloonPercent)
                     inflateMemBalloonHandler.postDelayed(
                         inflateMemBalloonTask,
-                        MEM_BALLOON_INFLATE_INTERVAL_MILLIS
-                    );
+                        MEM_BALLOON_INFLATE_INTERVAL_MILLIS,
+                    )
                 }
             }
             else -> {
@@ -440,7 +442,7 @@
         private const val INITIAL_MEM_BALLOON_PERCENT = 10
         private const val MAX_MEM_BALLOON_PERCENT = 50
         private const val MEM_BALLOON_INFLATE_INTERVAL_MILLIS = 60000L
-        private const val MEM_BALLOON_PERCENT_STEP = 5;
+        private const val MEM_BALLOON_PERCENT_STEP = 5
 
         private fun getMyIntent(context: Context): Intent {
             return Intent(context.getApplicationContext(), VmLauncherService::class.java)