summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson <winsonc@google.com> 2015-11-06 15:30:29 -0800
committer Winson <winsonc@google.com> 2015-11-06 15:30:29 -0800
commit13d30660ef6da2d924e4fc943ccd187767ee0cd2 (patch)
treeee41c4ee69903fa6e206849d9aab2f94f4615a0f
parent7395ef0cdb578aad27de3dbfc36dcde1e6f6a046 (diff)
Fixing issue with canceling the thumbnail in addition to the app window.
Bug: 25392381 Change-Id: Ib507f53bcd2aad4771c2546f5e8bfe771769e9a2
-rw-r--r--core/java/android/view/IWindowManager.aidl5
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/events/activity/CancelEnterRecentsWindowAnimationEvent.java34
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java21
-rw-r--r--services/core/java/com/android/server/wm/Task.java9
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java10
-rw-r--r--tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java4
8 files changed, 94 insertions, 27 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 28b22bf787ce..7b5f5abe7535 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -219,6 +219,11 @@ interface IWindowManager
*/
void cancelTaskWindowTransition(int taskId);
+ /**
+ * Cancels the thumbnail transitions for the given task.
+ */
+ void cancelTaskThumbnailTransition(int taskId);
+
// These can only be called with the SET_ORIENTATION permission.
/**
* Update the current screen rotation based on the current state of
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index af6df1da84c4..6874247e5fa3 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -41,6 +41,7 @@ import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEvent;
+import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationStartedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
@@ -355,12 +356,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
mRecentsView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
- mRecentsView.getViewTreeObserver().addOnEnterAnimationCompleteListener(new ViewTreeObserver.OnEnterAnimationCompleteListener() {
- @Override
- public void onEnterAnimationComplete() {
- System.out.println("ENTER ANIMATION COMPLETE");
- }
- });
mEmptyViewStub = (ViewStub) findViewById(R.id.empty_view_stub);
mScrimViews = new SystemBarScrimViews(this);
@@ -515,12 +510,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
if (event.getRepeatCount() <= 0 || hasRepKeyTimeElapsed) {
// As we iterate to the next/previous task, cancel any current/lagging window
// transition animations
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
- if (launchState.launchedToTaskId != -1) {
- SystemServicesProxy ssp = Recents.getSystemServices();
- ssp.cancelWindowTransition(launchState.launchedToTaskId);
- }
+ EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
// Focus the next task in the stack
final boolean backward = event.isShiftPressed();
@@ -657,6 +647,17 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
}
+ public final void onBusEvent(CancelEnterRecentsWindowAnimationEvent event) {
+ RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
+ int launchToTaskId = launchState.launchedToTaskId;
+ if (launchToTaskId != -1 &&
+ (event.launchTask == null || launchToTaskId != event.launchTask.key.id)) {
+ SystemServicesProxy ssp = Recents.getSystemServices();
+ ssp.cancelWindowTransition(launchState.launchedToTaskId);
+ ssp.cancelThumbnailTransition(getTaskId());
+ }
+ }
+
public final void onBusEvent(AppWidgetProviderChangedEvent event) {
refreshSearchWidgetView();
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/activity/CancelEnterRecentsWindowAnimationEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/activity/CancelEnterRecentsWindowAnimationEvent.java
new file mode 100644
index 000000000000..7604de1d05d0
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recents/events/activity/CancelEnterRecentsWindowAnimationEvent.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.recents.events.activity;
+
+import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.model.Task;
+
+/**
+ * This is sent when we want to cancel the enter-recents window animation for the launch task.
+ */
+public class CancelEnterRecentsWindowAnimationEvent extends EventBus.Event {
+
+ // This is set for the task that is launching, which allows us to ensure that we are not
+ // cancelling the same task animation (it will just be overwritten instead)
+ public final Task launchTask;
+
+ public CancelEnterRecentsWindowAnimationEvent(Task launchTask) {
+ this.launchTask = launchTask;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 8dca0640eca6..0432ac99de2f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -363,6 +363,19 @@ public class SystemServicesProxy {
}
}
+ /**
+ * Cancels the current thumbnail transtion to/from Recents for the given task id.
+ */
+ public void cancelThumbnailTransition(int taskId) {
+ if (mWm == null) return;
+
+ try {
+ WindowManagerGlobal.getWindowManagerService().cancelTaskThumbnailTransition(taskId);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
/** Returns the top task thumbnail for the given task id */
public Bitmap getTaskThumbnail(int taskId) {
if (mAm == null) return null;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index b131604c417e..5f94fa76f380 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -51,6 +51,7 @@ import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsAppWidgetHostView;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.EventBus;
+import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
@@ -106,6 +107,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
Rect mSystemInsets = new Rect();
+
@GuardedBy("this")
List<AppTransitionAnimationSpec> mAppTransitionAnimationSpecs;
@@ -245,6 +247,9 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
}
ctx.postAnimationTrigger.decrement();
+ // If we are going home, cancel the previous task's window transition
+ EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
+
// Notify of the exit animation
EventBus.getDefault().send(new DismissRecentsToHomeAnimationStarted());
}
@@ -554,20 +559,6 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
return new AppTransitionAnimationSpec(taskId, b, rect);
}
- /**
- * Cancels any running window transitions for the launched task (the task animating into
- * Recents).
- */
- private void cancelLaunchedTaskWindowTransition(final Task task) {
- SystemServicesProxy ssp = Recents.getSystemServices();
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
- if (launchState.launchedToTaskId != -1 &&
- launchState.launchedToTaskId != task.key.id) {
- ssp.cancelWindowTransition(launchState.launchedToTaskId);
- }
- }
-
/**** TaskStackView.TaskStackCallbacks Implementation ****/
@Override
@@ -605,7 +596,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
public void onAnimationStarted() {
// If we are launching into another task, cancel the previous task's
// window transition
- cancelLaunchedTaskWindowTransition(task);
+ EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
if (lockToTask) {
// Request screen pinning after the animation runs
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 5864b25781b0..6aaf3c72d4fc 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -328,6 +328,15 @@ class Task implements DimLayer.DimLayerUser {
}
}
+ /**
+ * Cancels any running thumbnail transitions associated with the task.
+ */
+ void cancelTaskThumbnailTransition() {
+ for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
+ mAppTokens.get(activityNdx).mAppAnimator.clearThumbnail();
+ }
+ }
+
boolean showForAllUsers() {
final int tokensCount = mAppTokens.size();
return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index bc34ba7789db..3205c6cca53f 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -4690,6 +4690,16 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
+ @Override
+ public void cancelTaskThumbnailTransition(int taskId) {
+ synchronized (mWindowMap) {
+ Task task = mTaskIdToTask.get(taskId);
+ if (task != null) {
+ task.cancelTaskThumbnailTransition();
+ }
+ }
+ }
+
public void addTask(int taskId, int stackId, boolean toTop) {
synchronized (mWindowMap) {
if (DEBUG_STACK) Slog.i(TAG, "addTask: adding taskId=" + taskId
diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
index 524aa9b062c1..3c260a83ecde 100644
--- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
+++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
@@ -535,6 +535,10 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
+ public void cancelTaskThumbnailTransition(int taskId) {
+ }
+
+ @Override
public void endProlongedAnimations() {
}
}