diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 8c781a13f7db3..08021f59eb066 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -539,7 +539,8 @@ final class InputMonitor { if (mAddRecentsAnimationInputConsumerHandle && shouldApplyRecentsInputConsumer) { if (recentsAnimationController.updateInputConsumerForApp( mRecentsAnimationInputConsumer.mWindowHandle)) { - mRecentsAnimationInputConsumer.show(mInputTransaction, w.mActivityRecord); + mRecentsAnimationInputConsumer.show(mInputTransaction, + recentsAnimationController.getHighestLayerTask()); mAddRecentsAnimationInputConsumerHandle = false; } } diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 4f93c7ad6ed97..c457df9f6e869 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -1102,6 +1102,23 @@ public class RecentsAnimationController implements DeathRecipient { return mTargetActivityRecord.findMainWindow(); } + /** + * Returns the task with the highest layer, or null if none is found. + */ + public Task getHighestLayerTask() { + int highestLayer = Integer.MIN_VALUE; + Task highestLayerTask = null; + for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { + TaskAnimationAdapter adapter = mPendingAnimations.get(i); + int layer = adapter.mTask.getPrefixOrderIndex(); + if (layer > highestLayer) { + highestLayer = layer; + highestLayerTask = adapter.mTask; + } + } + return highestLayerTask; + } + boolean isAnimatingTask(Task task) { for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { if (task == mPendingAnimations.get(i).mTask) {