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

Commit ec8ac6ba authored by Adrian Roos's avatar Adrian Roos
Browse files

InsetsAnimation: Fix crash if disabling decor fitting before view is attached

Bug: 149341851
Test: atest WindowTest
Change-Id: I6a688c493e79c0e95037dcc690c92fb33049dc95
parent 43361f71
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -1821,15 +1821,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    }

    private ViewRootImpl getViewRootImpl() {
        if (mDecor != null) {
            ViewRootImpl viewRootImpl = mDecor.getViewRootImpl();
        ViewRootImpl viewRootImpl = getViewRootImplOrNull();
        if (viewRootImpl != null) {
            return viewRootImpl;
        }
        }
        throw new IllegalStateException("view not added");
    }

    private ViewRootImpl getViewRootImplOrNull() {
        if (mDecor == null) {
            return null;
        }
        return mDecor.getViewRootImpl();
    }

    /**
     * Request that key events come to this activity. Use this if your activity
     * has no views with focus, but the activity still wants a chance to process
@@ -3900,7 +3905,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

    @Override
    public void setDecorFitsSystemWindows(boolean decorFitsSystemWindows) {
        ViewRootImpl impl = getViewRootImpl();
        ViewRootImpl impl = getViewRootImplOrNull();
        OnContentApplyWindowInsetsListener listener = decorFitsSystemWindows
                ? createDefaultContentWindowInsetsListener()
                : null;