diff options
| author | Mariia Sandrikova <mariiasand@google.com> | 2022-12-23 21:59:37 +0000 |
|---|---|---|
| committer | Mariia Sandrikova <mariiasand@google.com> | 2022-12-25 18:36:02 +0000 |
| commit | a35b67997d1745d6d66ef647ae8cfe5456e10ccc (patch) | |
| tree | 6077fe4edd3c9c197ac11c48c5e5d83574eccb6a /core/java/android/app/ActivityThread.java | |
| parent | d5a4b9e514fecfcac7de4f8a5d1b63372602afd6 (diff) | |
Enable forced focus for resumed split screen activities
This is needed because some game engines wait until they get focus before drawing the content of the app so they are blacked out when they are resumed and do not have focus yet.
Bug: 203398248
Test: atest FrameworksCoreTests:ViewRootImplTest#whenDispatchFakeFocus_noFocusAfterwards
Change-Id: I5675b32fbb9f60a7373fadbce379d571168436e7
Merged-In: I5675b32fbb9f60a7373fadbce379d571168436e7
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 2beb64d98c99..b26504dd1c49 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4164,7 +4164,8 @@ public final class ActivityThread extends ClientTransactionHandler private void scheduleResume(ActivityClientRecord r) { final ClientTransaction transaction = ClientTransaction.obtain(this.mAppThread, r.token); - transaction.setLifecycleStateRequest(ResumeActivityItem.obtain(/* isForward */ false)); + transaction.setLifecycleStateRequest(ResumeActivityItem.obtain(/* isForward */ false, + /* shouldSendCompatFakeFocus */ false)); executeTransaction(transaction); } @@ -4791,7 +4792,7 @@ public final class ActivityThread extends ClientTransactionHandler @Override public void handleResumeActivity(ActivityClientRecord r, boolean finalStateRequest, - boolean isForward, String reason) { + boolean isForward, boolean shouldSendCompatFakeFocus, String reason) { // If we are getting ready to gc after going to the background, well // we are back active so skip it. unscheduleGcIdler(); @@ -4898,6 +4899,16 @@ public final class ActivityThread extends ClientTransactionHandler if (r.activity.mVisibleFromClient) { r.activity.makeVisible(); } + + if (shouldSendCompatFakeFocus) { + // Attaching to a window is asynchronous with the activity being resumed, + // so it's possible we will need to send a fake focus event after attaching + if (impl != null) { + impl.dispatchCompatFakeFocus(); + } else { + r.window.getDecorView().fakeFocusAfterAttachingToWindow(); + } + } } r.nextIdle = mNewActivities; |
