Add focusTransferTarget in WindowInfo

A transfer focus request was originally added on FocusRequest object.
This meant when a host wanted to provide focus to an embedded window, it
would request to transfer focus, but provide its own token as the
focusedToken in the request. In FocusResolver, it would ensure that the
focusedToken was current focus before allow the request to proceed. This
worked in some cases, but created races where clients had to understand
timing in order to properly transfer focus.

The new code creates a persistent focusTransferTarget value on the
WindowInfo object. The host will add the embedded token as part of its
own WindowInfo#focusTransferTarget. When FocusResolver determines that
a window should gain focus, it will check to see if there is any
focusTransferTarget value set. If there is, it will attempt to give focus
to that window, if possible. Otherwise, it will fallback to the previous
window in the chain.

This solves a few issues with embedded windows.
1. Apps can request focus to the embedded by requesting focus to the SV
   that hosts the embedded. However, if they request focus too early, it
   will drop the request since the host has not yet gained focus. With
   the current code, it will transfer focus to the embedded once the
   host could have gained focus. If the host wants to revoke, the
   focusTransferTarget can be set to null, which will give the host focus
   again.

2. This fixes the issue if another window becomes focus. When WM gives
   focus back to the host window, it should automatically give focus to
   the embedded if it was last requested. The app shouldn't be required
   to maintain the last state of the embedded focus to see if it needs
   to transfer it again. It's actually not even possible once focus can
   be given to embedded via touch since only WM and Input know about
   this.

By adding focusTransferTarget to WindowInfo, the focusedToken value in
FocusRequest can be removed, as well.

Test: InputDispatcher_test
Test: FocusResolver_test
Test: WindowInfo_test
Bug: 230340812
Change-Id: I252403184f7060c37c82353638ac6ee25a0979fc
diff --git a/libs/gui/WindowInfo.cpp b/libs/gui/WindowInfo.cpp
index 804ce4f..6df9ff1 100644
--- a/libs/gui/WindowInfo.cpp
+++ b/libs/gui/WindowInfo.cpp
@@ -125,6 +125,7 @@
         parcel->writeBool(replaceTouchableRegionWithCrop) ?:
         parcel->writeStrongBinder(touchableRegionCropHandle.promote()) ?:
         parcel->writeStrongBinder(windowToken);
+        parcel->writeStrongBinder(focusTransferTarget);
     // clang-format on
     return status;
 }
@@ -175,7 +176,9 @@
         parcel->read(touchableRegion) ?:
         parcel->readBool(&replaceTouchableRegionWithCrop) ?:
         parcel->readNullableStrongBinder(&touchableRegionCropHandleSp) ?:
-        parcel->readNullableStrongBinder(&windowToken);
+        parcel->readNullableStrongBinder(&windowToken) ?:
+        parcel->readNullableStrongBinder(&focusTransferTarget);
+
     // clang-format on
 
     if (status != OK) {