From ab20e1623b81076357a08cebeda7e58cbf3e1891 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 27 Mar 2018 13:06:09 +0200 Subject: [PATCH] Clear calling identity in finish callback Test: go/wm-smoke Fixes: 76138720 Change-Id: Id6b1afd757d4374a401abe4ee68fe99ed182a62e --- .../server/wm/RemoteAnimationController.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java index c5900677e41e9..b02a74e17f43a 100644 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java @@ -16,14 +16,15 @@ package com.android.server.wm; +import static com.android.server.wm.AnimationAdapterProto.REMOTE; +import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; -import static com.android.server.wm.AnimationAdapterProto.REMOTE; -import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET; import android.graphics.Point; import android.graphics.Rect; +import android.os.Binder; import android.os.Handler; import android.os.RemoteException; import android.os.SystemClock; @@ -194,12 +195,17 @@ class RemoteAnimationController { @Override public void onAnimationFinished() throws RemoteException { - if (mOuter != null) { - mOuter.onAnimationFinished(); + final long token = Binder.clearCallingIdentity(); + try { + if (mOuter != null) { + mOuter.onAnimationFinished(); - // In case the client holds on to the finish callback, make sure we don't leak - // RemoteAnimationController which in turn would leak the runner on the client. - mOuter = null; + // In case the client holds on to the finish callback, make sure we don't leak + // RemoteAnimationController which in turn would leak the runner on the client. + mOuter = null; + } + } finally { + Binder.restoreCallingIdentity(token); } }