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

Commit c7e52d75 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Remove dead code in window manager."

parents d8031f0e 23e7c35a
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -251,8 +251,6 @@ public final class ViewRootImpl implements ViewParent,

    CompatibilityInfoHolder mCompatibilityInfo;

    /*package*/ int mAddNesting;

    // These are accessed by multiple threads.
    final Rect mWinFrame; // frame given by window manager.

+17 −66
Original line number Diff line number Diff line
@@ -217,15 +217,10 @@ public class WindowManagerImpl implements WindowManager {
    }

    public void addView(View view, ViewGroup.LayoutParams params) {
        addView(view, params, null, false);
        addView(view, params, null);
    }
    
    public void addView(View view, ViewGroup.LayoutParams params, CompatibilityInfoHolder cih) {
        addView(view, params, cih, false);
    }
    
    private void addView(View view, ViewGroup.LayoutParams params,
            CompatibilityInfoHolder cih, boolean nest) {
        if (false) Log.v("WindowManager", "addView view=" + view);

        if (!(params instanceof WindowManager.LayoutParams)) {
@@ -256,26 +251,11 @@ public class WindowManagerImpl implements WindowManager {
                SystemProperties.addChangeCallback(mSystemPropertyUpdater);
            }

            // Here's an odd/questionable case: if someone tries to add a
            // view multiple times, then we simply bump up a nesting count
            // and they need to remove the view the corresponding number of
            // times to have it actually removed from the window manager.
            // This is useful specifically for the notification manager,
            // which can continually add/remove the same view as a
            // notification gets updated.
            int index = findViewLocked(view, false);
            if (index >= 0) {
                if (!nest) {
                throw new IllegalStateException("View " + view
                        + " has already been added to the window manager.");
            }
                root = mRoots[index];
                root.mAddNesting++;
                // Update layout parameters.
                view.setLayoutParams(wparams);
                root.setLayoutParams(wparams, true);
                return;
            }
            
            // If this is a panel window, then find the window it is being
            // attached to for future reference.
@@ -290,7 +270,6 @@ public class WindowManagerImpl implements WindowManager {
            }
            
            root = new ViewRootImpl(view.getContext());
            root.mAddNesting = 1;
            if (cih == null) {
                root.mCompatibilityInfo = new CompatibilityInfoHolder();
            } else {
@@ -345,35 +324,17 @@ public class WindowManagerImpl implements WindowManager {
    }

    public void removeView(View view) {
        synchronized (this) {
            int index = findViewLocked(view, true);
            View curView = removeViewLocked(index);
            if (curView == view) {
                return;
        removeView(view, false);
    }

            throw new IllegalStateException("Calling with view " + view
                    + " but the ViewAncestor is attached to " + curView);
        }
    public void removeViewImmediate(View view) {
        removeView(view, true);
    }

    public void removeViewImmediate(View view) {
    private void removeView(View view, boolean immediate) {
        synchronized (this) {
            int index = findViewLocked(view, true);
            ViewRootImpl root = mRoots[index];
            View curView = root.getView();
            
            root.mAddNesting = 0;

            if (view != null) {
                InputMethodManager imm = InputMethodManager.getInstance(view.getContext());
                if (imm != null) {
                    imm.windowDismissed(mViews[index].getWindowToken());
                }
            }

            root.die(true);
            finishRemoveViewLocked(curView, index);
            View curView = removeViewLocked(index, immediate);
            if (curView == view) {
                return;
            }
@@ -383,28 +344,18 @@ public class WindowManagerImpl implements WindowManager {
        }
    }

    View removeViewLocked(int index) {
    View removeViewLocked(int index, boolean immediate) {
        ViewRootImpl root = mRoots[index];
        View view = root.getView();

        // Don't really remove until we have matched all calls to add().
        root.mAddNesting--;
        if (root.mAddNesting > 0) {
            return view;
        }

        if (view != null) {
            InputMethodManager imm = InputMethodManager.getInstance(view.getContext());
            if (imm != null) {
                imm.windowDismissed(mViews[index].getWindowToken());
            }
        }
        root.die(false);
        finishRemoveViewLocked(view, index);
        return view;
    }
        root.die(immediate);

    void finishRemoveViewLocked(View view, int index) {
        final int count = mViews.length;

        // remove it from the list
@@ -426,6 +377,7 @@ public class WindowManagerImpl implements WindowManager {
            // func doesn't allow null...  does it matter if we clear them?
            //view.setLayoutParams(null);
        }
        return view;
    }

    public void closeAll(IBinder token, String who, String what) {
@@ -440,7 +392,6 @@ public class WindowManagerImpl implements WindowManager {
                //        + " view " + mRoots[i].getView());
                if (token == null || mParams[i].token == token) {
                    ViewRootImpl root = mRoots[i];
                    root.mAddNesting = 1;

                    //Log.i("foo", "Force closing " + root);
                    if (who != null) {
@@ -451,7 +402,7 @@ public class WindowManagerImpl implements WindowManager {
                        Log.e("WindowManager", leak.getMessage(), leak);
                    }

                    removeViewLocked(i);
                    removeViewLocked(i, false);
                    i--;
                    count--;
                }