From 46e631178e3420fee182e7d9d1ddfdbca9355bc1 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 9 Dec 2013 17:38:05 -0800 Subject: [PATCH] DO NOT MERGE - Fix memory leak caused by mismatched linkToDeath() in WindowManagerService This fixes a bug where an allocated DeathRecipient in WindowManagerService was holding a reference to keyguard binder interface after a call to linkToDeath() without a matchin unlinkToDeath(). It was causing the keyguard side of the binder interface to stick around, which in tern prevented the keyguard side from releasing its references. The solution is to ensure matching linkToDeath()/unlinkToDeath() calls. Fixes bug 11982048 Change-Id: I6959816b819ba953512c53675162195cbf1e0653 --- .../android/server/wm/WindowManagerService.java | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 3ed507656fd6..64bbe49342d9 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -437,8 +437,15 @@ public class WindowManagerService extends IWindowManager.Stub int mRotation = 0; int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; boolean mAltOrientation = false; - ArrayList mRotationWatchers - = new ArrayList(); + class RotationWatcher { + IRotationWatcher watcher; + IBinder.DeathRecipient dr; + RotationWatcher(IRotationWatcher w, IBinder.DeathRecipient d) { + watcher = w; + dr = d; + } + } + ArrayList mRotationWatchers = new ArrayList(); int mDeferredRotationPauseCount; int mSystemDecorLayer = 0; @@ -5993,7 +6000,7 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=mRotationWatchers.size()-1; i>=0; i--) { try { - mRotationWatchers.get(i).onRotationChanged(rotation); + mRotationWatchers.get(i).watcher.onRotationChanged(rotation); } catch (RemoteException e) { } } @@ -6025,10 +6032,10 @@ public class WindowManagerService extends IWindowManager.Stub public void binderDied() { synchronized (mWindowMap) { for (int i=0; i