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

Commit 5c4db5f3 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Bail out early if activityInfo=null

When PipEnterAnimator attempts to create an app icon
overlay with the activityInfo=null, we should bail out
early to avoid trying to get the app icon.

Bug: 429221694
Flag: com.android.wm.shell.enable_pip2
Test: atest PipEnterAnimatorTest
Change-Id: I1e4b28c66ef64cfb22a4bba5626ef4eba3a8d337
parent ce48679b
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -36,11 +36,13 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.ProtoLog;
import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.R;
import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.pip2.PipSurfaceTransactionHelper;
import com.android.wm.shell.pip2.phone.PipAppIconOverlay;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.shared.animation.Interpolators;
import com.android.wm.shell.shared.pip.PipContentOverlay;

@@ -48,6 +50,7 @@ import com.android.wm.shell.shared.pip.PipContentOverlay;
 * Animator that handles bounds animations for entering PIP.
 */
public class PipEnterAnimator extends ValueAnimator {
    private static final String TAG = PipEnterAnimator.class.getSimpleName();
    @NonNull private final SurfaceControl mLeash;
    private final SurfaceControl.Transaction mStartTransaction;
    private final SurfaceControl.Transaction mFinishTransaction;
@@ -212,8 +215,10 @@ public class PipEnterAnimator extends ValueAnimator {
        }
        mContentOverlay = mPipAppIconOverlaySupplier.get(context, appBounds, destinationBounds,
                activityInfo, appIconSizePx);
        if (mContentOverlay != null) {
            mContentOverlay.attach(tx, mLeash);
        }
    }

    /**
     * Clears the {@link #mContentOverlay}, this should be done after the content overlay is
@@ -228,9 +233,15 @@ public class PipEnterAnimator extends ValueAnimator {
        mContentOverlay = null;
    }

    @Nullable
    private PipAppIconOverlay getAppIconOverlay(
            Context context, Rect appBounds, Rect destinationBounds,
            ActivityInfo activityInfo, int iconSize) {
        if (activityInfo == null) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                    "%s: activityInfo=null when trying to add app icon overlay", TAG);
            return null;
        }
        return new PipAppIconOverlay(context, appBounds, destinationBounds,
                new IconProvider(context).getIcon(activityInfo), iconSize);
    }