From 11f232ce5dbc4c043ca088a866518f5ab9018c41 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 28 Apr 2021 23:18:16 +0800 Subject: [PATCH] Disable fixed rotation for starting window with ime surface The IME window may show later depends on whether the task snapshot contains the snapshot of IME surface, and whether the edit view is still focused. If display orientation is changed, IME window may take longer time to redraw. That requires to adjust the timing of the removal starting window to avoid flickering. For short term, just fallback the case to legacy behavior that applies normal screen rotation animation. Bug: 160451808 Test: Launch a landscape app which opens IME from portrait home. Return to home and launch it again. The IME window isn't flickering in 2 orientations. Change-Id: Idfdf129adbfbee6634d8a27aa78da1f631bd213b --- services/core/java/com/android/server/wm/DisplayContent.java | 5 +++++ .../java/com/android/server/wm/SnapshotStartingData.java | 5 +++++ services/core/java/com/android/server/wm/StartingData.java | 5 +++++ .../com/android/server/wm/StartingSurfaceController.java | 4 +++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 0c4e1a2c0aaed..d1827be7e424c 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1538,6 +1538,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // to cover the activity configuration change. return false; } + if (r.mStartingData != null && r.mStartingData.hasImeSurface()) { + // Currently it is unknown that when will IME window be ready. Reject the case to + // avoid flickering by showing IME in inconsistent orientation. + return false; + } if (checkOpening) { if (!mAppTransition.isTransitionSet() || !mOpeningApps.contains(r)) { // Apply normal rotation animation in case of the activity set different requested diff --git a/services/core/java/com/android/server/wm/SnapshotStartingData.java b/services/core/java/com/android/server/wm/SnapshotStartingData.java index 2124ed6fd39fc..66ae0eb9b48f8 100644 --- a/services/core/java/com/android/server/wm/SnapshotStartingData.java +++ b/services/core/java/com/android/server/wm/SnapshotStartingData.java @@ -39,4 +39,9 @@ class SnapshotStartingData extends StartingData { return mService.mStartingSurfaceController.createTaskSnapshotSurface(activity, mSnapshot); } + + @Override + boolean hasImeSurface() { + return mSnapshot.hasImeSurface(); + } } diff --git a/services/core/java/com/android/server/wm/StartingData.java b/services/core/java/com/android/server/wm/StartingData.java index a5bd797cbc866..59de43ac95a38 100644 --- a/services/core/java/com/android/server/wm/StartingData.java +++ b/services/core/java/com/android/server/wm/StartingData.java @@ -40,4 +40,9 @@ public abstract class StartingData { * {@link StartingSurface#remove} */ abstract StartingSurface createStartingSurface(ActivityRecord activity); + + /** @see android.window.TaskSnapshot#hasImeSurface() */ + boolean hasImeSurface() { + return false; + } } diff --git a/services/core/java/com/android/server/wm/StartingSurfaceController.java b/services/core/java/com/android/server/wm/StartingSurfaceController.java index a9b06ca5042b5..c3815c1e17965 100644 --- a/services/core/java/com/android/server/wm/StartingSurfaceController.java +++ b/services/core/java/com/android/server/wm/StartingSurfaceController.java @@ -118,7 +118,9 @@ public class StartingSurfaceController { return null; } if (topFullscreenActivity.getWindowConfiguration().getRotation() - != taskSnapshot.getRotation()) { + != taskSnapshot.getRotation() + // Use normal rotation to avoid flickering of IME window in old orientation. + && !taskSnapshot.hasImeSurface()) { // The snapshot should have been checked by ActivityRecord#isSnapshotCompatible // that the activity will be updated to the same rotation as the snapshot. Since // the transition is not started yet, fixed rotation transform needs to be applied