diff options
author | Roman Birg <roman@cyngn.com> | 2015-10-02 11:36:31 -0700 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-05-05 17:22:29 +0100 |
commit | a429e470bbc079115d0cda0a3b48ddaee5811a0e (patch) | |
tree | f84e8a6c123ceff0b89fd3fa73c84b4ceead52ea | |
parent | 26c932ea37148f4d336e6a69adf057bf8ddcb09e (diff) | |
download | frameworks_base-a429e470bbc079115d0cda0a3b48ddaee5811a0e.zip frameworks_base-a429e470bbc079115d0cda0a3b48ddaee5811a0e.tar.gz frameworks_base-a429e470bbc079115d0cda0a3b48ddaee5811a0e.tar.bz2 |
SystemUI: bail out of recents-to-home animation when losing focus
In the case when recents is animating out, and an application happens to
immediately add a view to the window manager, the recents view would
lose its focus, but the animations would continue to run, breaking the
behavior in certain cases.
Bail out of the recents activity and override the pending transition to
be disabled to not distrubt the newly added window.
Ref: CYNGNOS-1136
Change-Id: I5998a9dcf21b1369473f04ea4d867c5f2543d6df
Signed-off-by: Roman Birg <roman@cyngn.com>
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index f4fe677..9e08599 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -85,6 +85,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView // Runnable to be executed after we paused ourselves Runnable mAfterPauseRunnable; + private ReferenceCountedTrigger mExitTrigger; + /** * A common Runnable to finish Recents either by calling finish() (with a custom animation) or * launching Home with some ActivityOptions. Generally we always launch home when we exit @@ -95,6 +97,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView class FinishRecentsRunnable implements Runnable { Intent mLaunchIntent; ActivityOptions mLaunchOpts; + boolean mAbort = false; /** * Creates a finish runnable that starts the specified intent, using the given @@ -105,8 +108,15 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView mLaunchOpts = opts; } + public void setAbort(boolean run) { + this.mAbort = run; + } + @Override public void run() { + if (mAbort) { + return; + } // Finish Recents if (mLaunchIntent != null) { try { @@ -317,13 +327,26 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView return false; } + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (!hasFocus && mExitTrigger != null && mExitTrigger.getCount() > 0) { + // we are animating recents out and the window has lost focus during the + // animation. we need to stop everything we're doing now and get out + // without any animations (since we were already animating) + mFinishLaunchHomeRunnable.setAbort(true); + finish(); + overridePendingTransition(0, 0); + } + } + /** Dismisses Recents directly to Home. */ void dismissRecentsToHomeRaw(boolean animated) { if (animated) { - ReferenceCountedTrigger exitTrigger = new ReferenceCountedTrigger(this, + mExitTrigger = new ReferenceCountedTrigger(this, null, mFinishLaunchHomeRunnable, null); mRecentsView.startExitToHomeAnimation( - new ViewAnimation.TaskViewExitContext(exitTrigger)); + new ViewAnimation.TaskViewExitContext(mExitTrigger)); } else { mFinishLaunchHomeRunnable.run(); } @@ -458,6 +481,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView @Override protected void onStop() { super.onStop(); + + mExitTrigger = null; + MetricsLogger.hidden(this, MetricsLogger.OVERVIEW_ACTIVITY); RecentsTaskLoader loader = RecentsTaskLoader.getInstance(); SystemServicesProxy ssp = loader.getSystemServicesProxy(); |