Merge restartInput into startInput in internal IPC

This is the 2nd attempt to merge restartInput into startInput in
internal IPC after fixing the mistake in new parameter order in
the previous CL [1].

As a preparation to start tracking all the event flows that
cause InputMethodManagerService#setImeWindowStatus(), this CL
merges an internal IPC method IInputMethod#restartInput() into
IInputMethod#startInput() in favor of simplicity.

This is a refactoring CL that should have no behavior change.

 [1]: Ifda6f74ac1b1370d9e9a9fe60354b692121fdcb9
      1a5838e966eab7a9f0dca71cabbc9922babb995e

Test: Set true to InputMethodService#DEBUG and make sure startInput()
      and restartInput() are called in the following scenario.
      1. Complete the setup wizard.
      2. adb shell am start -a android.app.action.SET_NEW_PASSWORD
      3. Proceed to "Choose your password" page
      4. Make sure startInput() gets called.
      5. Type "aaaa" then hit "CONTINUE" button.
      6. Make sure restartInput() gets called.
Bug: 35079353
Change-Id: I476d0cf8cbb0a0134941854f9337d9ad15e66a71
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 2b3d8d4..b9c47e7 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -175,7 +175,6 @@
     static final int MSG_CREATE_SESSION = 1050;
 
     static final int MSG_START_INPUT = 2000;
-    static final int MSG_RESTART_INPUT = 2010;
 
     static final int MSG_UNBIND_CLIENT = 3000;
     static final int MSG_BIND_CLIENT = 3010;
@@ -1340,15 +1339,9 @@
             mBoundToMethod = true;
         }
         final SessionState session = mCurClient.curSession;
-        if (initial) {
-            executeOrSendMessage(session.method, mCaller.obtainMessageIOOO(
-                    MSG_START_INPUT, mCurInputContextMissingMethods, session, mCurInputContext,
-                    mCurAttribute));
-        } else {
-            executeOrSendMessage(session.method, mCaller.obtainMessageIOOO(
-                    MSG_RESTART_INPUT, mCurInputContextMissingMethods, session, mCurInputContext,
-                    mCurAttribute));
-        }
+        executeOrSendMessage(session.method, mCaller.obtainMessageIIOOO(
+                MSG_START_INPUT, mCurInputContextMissingMethods, initial ? 0 : 1 /* restarting */,
+                session, mCurInputContext, mCurAttribute));
         if (mShowRequested) {
             if (DEBUG) Slog.v(TAG, "Attach new input asks to show input");
             showCurrentInputLocked(getAppShowFlags(), null);
@@ -2896,26 +2889,15 @@
             // ---------------------------------------------------------
 
             case MSG_START_INPUT: {
-                int missingMethods = msg.arg1;
+                final int missingMethods = msg.arg1;
+                final boolean restarting = msg.arg2 != 0;
                 args = (SomeArgs) msg.obj;
+                final SessionState session = (SessionState) args.arg1;
+                final IInputContext inputContext = (IInputContext) args.arg2;
+                final EditorInfo editorInfo = (EditorInfo) args.arg3;
                 try {
-                    SessionState session = (SessionState) args.arg1;
                     setEnabledSessionInMainThread(session);
-                    session.method.startInput((IInputContext) args.arg2, missingMethods,
-                            (EditorInfo) args.arg3);
-                } catch (RemoteException e) {
-                }
-                args.recycle();
-                return true;
-            }
-            case MSG_RESTART_INPUT: {
-                int missingMethods = msg.arg1;
-                args = (SomeArgs) msg.obj;
-                try {
-                    SessionState session = (SessionState) args.arg1;
-                    setEnabledSessionInMainThread(session);
-                    session.method.restartInput((IInputContext) args.arg2, missingMethods,
-                            (EditorInfo) args.arg3);
+                    session.method.startInput(inputContext, missingMethods, editorInfo, restarting);
                 } catch (RemoteException e) {
                 }
                 args.recycle();