summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2014-10-28 19:59:59 -0700
committerCraig Mautner <cmautner@google.com>2014-10-30 14:43:18 -0700
commit9c79504225f60c72c947220b6aca928f11279e1c (patch)
tree59730a317b8b7d976ff2032f790916abbc8bb862 /services
parent74fe6ce72dcbc7af501022e7617528c30a0983bb (diff)
downloadframeworks_base-9c79504225f60c72c947220b6aca928f11279e1c.zip
frameworks_base-9c79504225f60c72c947220b6aca928f11279e1c.tar.gz
frameworks_base-9c79504225f60c72c947220b6aca928f11279e1c.tar.bz2
Add enter-animation-done callback for system windows
Existing hidden methods allow activities to be notified when their windows have completed animating in. This change adds that capability to system windows using a ViewTreeObserver callback since system windows lack an activity token. The first subsystem to use this is the UserSwitchingDialog which was previously using a 250 msec timeout to dismiss the dialog. That deadline was often missed leaving the user with no dialog on the screen during the transition. Fixes bug 16661752. Change-Id: I70789e0d9c07112f275e76fb82850926305f290d
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/am/UserSwitchingDialog.java37
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java6
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java14
3 files changed, 35 insertions, 22 deletions
diff --git a/services/core/java/com/android/server/am/UserSwitchingDialog.java b/services/core/java/com/android/server/am/UserSwitchingDialog.java
index dfc8df5..36263ec 100644
--- a/services/core/java/com/android/server/am/UserSwitchingDialog.java
+++ b/services/core/java/com/android/server/am/UserSwitchingDialog.java
@@ -17,17 +17,11 @@
package com.android.server.am;
import android.app.AlertDialog;
-import android.app.Service;
-import android.content.ActivityNotFoundException;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
import android.content.res.Resources;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.TextView;
@@ -39,11 +33,10 @@ import com.android.internal.R;
* in the background rather than just freeze the screen and not know if the user-switch affordance
* was being handled.
*/
-final class UserSwitchingDialog extends AlertDialog {
+final class UserSwitchingDialog extends AlertDialog
+ implements ViewTreeObserver.OnWindowShownListener {
private static final String TAG = "ActivityManagerUserSwitchingDialog";
- private static final int MSG_START_USER = 1;
-
private final ActivityManagerService mService;
private final int mUserId;
@@ -74,19 +67,21 @@ final class UserSwitchingDialog extends AlertDialog {
@Override
public void show() {
+ // Slog.v(TAG, "show called");
super.show();
- // TODO: Instead of just an arbitrary delay, wait for a signal that the window was fully
- // displayed by the window manager
- mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_START_USER), 250);
+ final View decorView = getWindow().getDecorView();
+ if (decorView != null) {
+ decorView.getViewTreeObserver().addOnWindowShownListener(this);
+ }
}
- private final Handler mHandler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_START_USER:
- mService.startUserInForeground(mUserId, UserSwitchingDialog.this);
- break;
- }
+ @Override
+ public void onWindowShown() {
+ // Slog.v(TAG, "onWindowShown called");
+ mService.startUserInForeground(mUserId, this);
+ final View decorView = getWindow().getDecorView();
+ if (decorView != null) {
+ decorView.getViewTreeObserver().removeOnWindowShownListener(this);
}
- };
+ }
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 0e55c1c..8c4e7b0 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2487,7 +2487,9 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
- win.mWinAnimator.mEnterAnimationPending = true;
+ final WindowStateAnimator winAnimator = win.mWinAnimator;
+ winAnimator.mEnterAnimationPending = true;
+ winAnimator.mEnteringAnimation = true;
if (displayContent.isDefaultDisplay) {
mPolicy.getContentInsetHintLw(attrs, outContentInsets);
@@ -3099,6 +3101,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (oldVisibility == View.GONE) {
winAnimator.mEnterAnimationPending = true;
}
+ winAnimator.mEnteringAnimation = true;
if (toBeDisplayed) {
if (win.isDrawnLw() && okToDisplay()) {
winAnimator.applyEnterAnimationLocked();
@@ -3167,6 +3170,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
} else {
winAnimator.mEnterAnimationPending = false;
+ winAnimator.mEnteringAnimation = false;
if (winAnimator.mSurfaceControl != null) {
if (DEBUG_VISIBILITY) Slog.i(TAG, "Relayout invis " + win
+ ": mExiting=" + win.mExiting);
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 0c727f3..fc3f2c2 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -40,6 +40,7 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.os.Debug;
+import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Slog;
import android.view.Display;
@@ -141,6 +142,11 @@ class WindowStateAnimator {
// an enter animation.
boolean mEnterAnimationPending;
+ /** Used to indicate that this window is undergoing an enter animation. Used for system
+ * windows to make the callback to View.dispatchOnWindowShownCallback(). Set when the
+ * window is first added or shown, cleared when the callback has been made. */
+ boolean mEnteringAnimation;
+
boolean keyguardGoingAwayAnimation;
/** This is set when there is no Surface */
@@ -428,6 +434,14 @@ class WindowStateAnimator {
mWin.mChildWindows.get(i).mWinAnimator.finishExit();
}
+ if (mEnteringAnimation && mWin.mAppToken == null) {
+ try {
+ mEnteringAnimation = false;
+ mWin.mClient.dispatchWindowShown();
+ } catch (RemoteException e) {
+ }
+ }
+
if (!mWin.mExiting) {
return;
}