OSDN Git Service

Skip Pip animation to fullscreen if orientation is going to change
authorWale Ogunwale <ogunwale@google.com>
Tue, 2 May 2017 04:32:58 +0000 (21:32 -0700)
committerWale Ogunwale <ogunwale@google.com>
Tue, 2 May 2017 22:02:49 +0000 (22:02 +0000)
Having this kind of animation look good is extremely difficult.
The best we can do is skip the animation and just go to fullscreen
if we know the device orientation is going to change because the
current screen configuration isn't compatible with the fixed
orientation requested by the app going fullscreen.

Change-Id: I97b14723a0d678c05efedc93fe692ad3b3212a72
Fixes: 37722472
Test: manual

services/core/java/com/android/server/am/ActivityRecord.java
services/core/java/com/android/server/am/ActivityStack.java
services/core/java/com/android/server/am/PinnedActivityStack.java

index 44caaf9..18c8b32 100644 (file)
@@ -2278,7 +2278,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
     }
 
     /** Returns true if the configuration is compatible with this activity. */
-    private boolean isConfigurationCompatible(Configuration config) {
+    boolean isConfigurationCompatible(Configuration config) {
         final int orientation = mWindowContainerController != null
                 ? mWindowContainerController.getOrientation() : info.screenOrientation;
         if (isFixedOrientationPortrait(orientation)
index 39fef44..912b22c 100644 (file)
@@ -655,11 +655,11 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
         }
     }
 
-    final ActivityRecord topRunningActivityLocked() {
+    ActivityRecord topRunningActivityLocked() {
         return topRunningActivityLocked(false /* focusableOnly */);
     }
 
-    final ActivityRecord topRunningActivityLocked(boolean focusableOnly) {
+    private ActivityRecord topRunningActivityLocked(boolean focusableOnly) {
         for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
             ActivityRecord r = mTaskHistory.get(taskNdx).topRunningActivityLocked();
             if (r != null && (!focusableOnly || r.isFocusable())) {
@@ -669,7 +669,21 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
         return null;
     }
 
-    final ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) {
+    ActivityRecord topRunningNonOverlayTaskActivity() {
+        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
+            final TaskRecord task = mTaskHistory.get(taskNdx);
+            final ArrayList<ActivityRecord> activities = task.mActivities;
+            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
+                final ActivityRecord r = activities.get(activityNdx);
+                if (!r.finishing && !r.mTaskOverlay) {
+                    return r;
+                }
+            }
+        }
+        return null;
+    }
+
+    ActivityRecord topRunningNonDelayedActivityLocked(ActivityRecord notTop) {
         for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
             final TaskRecord task = mTaskHistory.get(taskNdx);
             final ArrayList<ActivityRecord> activities = task.mActivities;
index 672f563..34cdb54 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.server.am;
 
 import android.app.RemoteAction;
+import android.content.res.Configuration;
 import android.graphics.Rect;
 
 import com.android.server.am.ActivityStackSupervisor.ActivityContainer;
@@ -50,8 +51,21 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController>
 
     void animateResizePinnedStack(Rect sourceHintBounds, Rect toBounds, int animationDuration,
             boolean schedulePipModeChangedOnAnimationEnd) {
-        getWindowContainerController().animateResizePinnedStack(toBounds, sourceHintBounds,
-                animationDuration, schedulePipModeChangedOnAnimationEnd);
+        if (skipResizeAnimation(toBounds == null /* toFullscreen */)) {
+            mService.moveTasksToFullscreenStack(mStackId, true /* onTop */);
+        } else {
+            getWindowContainerController().animateResizePinnedStack(toBounds, sourceHintBounds,
+                    animationDuration, schedulePipModeChangedOnAnimationEnd);
+        }
+    }
+
+    private boolean skipResizeAnimation(boolean toFullscreen) {
+        if (!toFullscreen) {
+            return false;
+        }
+        final Configuration parentConfig = getParent().getConfiguration();
+        final ActivityRecord top = topRunningNonOverlayTaskActivity();
+        return top != null && !top.isConfigurationCompatible(parentConfig);
     }
 
     void setPictureInPictureAspectRatio(float aspectRatio) {