Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1443e99 authored by Mathias Jeppsson's avatar Mathias Jeppsson Committed by Zoran Jovanovic
Browse files

Fix starting window memory leak

If starting window is added to arrays like mViews in
WindowManagerImpl.java, but not accepted by WindowManagerService,
we leak starting windows. To avoid leaking, remove the view
from WindowManager.

Change-Id: I4d98b883e9dfaf5e71bdece385643ba1b59b2633
parent c5748148
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1523,6 +1523,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            return null;
        }

        WindowManager wm = null;
        View view = null;

        try {
            Context context = mContext;
            if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName
@@ -1582,8 +1585,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
            params.setTitle("Starting " + packageName);

            WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
            View view = win.getDecorView();
            wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
            view = win.getDecorView();

            if (win.isFloating()) {
                // Whoops, there is no way to display an animation/preview
@@ -1613,6 +1616,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            // failure loading resources because we are loading from an app
            // on external storage that has been unmounted.
            Log.w(TAG, appToken + " failed creating starting window", e);
        } finally {
            if (view != null && view.getParent() == null) {
                Log.w(TAG, "view not successfully added to wm, removing view");
                wm.removeViewImmediate(view);
            }
        }

        return null;