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

Commit d4be328e authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Check if surfacecontrol is valid in getBufferTransformHint

Fixes a crash when app queries the buffer transform hint but
VIMPL's surfacecontrol is not valid. We should fail gracefully
by providing a default since its hard for the caller to always
know when the surfacecontrol is valid.

Fixes: 301201605
Test: presubmit
Change-Id: I27ce4608bb0de5cbb41afd78d9cd1eb40729e96a
parent 279533e7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -92,6 +92,12 @@ public interface AttachedSurfaceControl {
     * SurfaceView Surface, the buffer producer will already have access to the transform hint and
     * no additional work is needed.
     *
     * If the root surface is not available, the API will return {@code BUFFER_TRANSFORM_IDENTITY}.
     * The caller should register a listener to listen for any changes. @see
     * {@link #addOnBufferTransformHintChangedListener(OnBufferTransformHintChangedListener)}.
     * Warning: Calling this API in Android 14 (API Level 34) or earlier will crash if the root
     * surface is not available.
     *
     * @see HardwareBuffer
     */
    default @SurfaceControl.BufferTransform int getBufferTransformHint() {
+5 −1
Original line number Diff line number Diff line
@@ -11440,7 +11440,11 @@ public final class ViewRootImpl implements ViewParent,

    @Override
    public @SurfaceControl.BufferTransform int getBufferTransformHint() {
        if (mSurfaceControl.isValid()) {
            return mSurfaceControl.getTransformHint();
        } else {
            return SurfaceControl.BUFFER_TRANSFORM_IDENTITY;
        }
    }

    @Override