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

Commit 3f0edea3 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an NPE in the RegionSamplingHelper

Apparently the viewRootImpl can be null as well, handling
that too now.

Fixes: 132436973
Test: manual, try back affordance
Change-Id: I3a1a2dbef62fc1928d0efac437a77d5654975689
parent b8eb195e
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.provider.Settings;
import android.view.CompositionSamplingListener;
import android.view.SurfaceControl;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;

import com.android.systemui.R;
@@ -153,8 +154,12 @@ public class RegionSamplingHelper implements View.OnAttachStateChangeListener,
        boolean isSamplingEnabled = mSamplingEnabled && !mSamplingRequestBounds.isEmpty()
                && (mSampledView.isAttachedToWindow() || mFirstSamplingAfterStart);
        if (isSamplingEnabled) {
            SurfaceControl stopLayerControl = mSampledView.getViewRootImpl().getSurfaceControl();
            if (!stopLayerControl.isValid()) {
            ViewRootImpl viewRootImpl = mSampledView.getViewRootImpl();
            SurfaceControl stopLayerControl = null;
            if (viewRootImpl != null) {
                 stopLayerControl = viewRootImpl.getSurfaceControl();
            }
            if (stopLayerControl == null || !stopLayerControl.isValid()) {
                if (!mWaitingOnDraw) {
                    mWaitingOnDraw = true;
                    // The view might be attached but we haven't drawn yet, so wait until the