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

Commit d60baf93 authored by Garfield Tan's avatar Garfield Tan Committed by android-build-merger
Browse files

Merge "Add a null check in case the display is missing." into pi-dev am: 7a4a3599

am: 61fb639a

Change-Id: I7c9dcc4727acfbceffe6f4c72dcc44bf30bcdc1b
parents b56368c9 61fb639a
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.server.wm.proto.ScreenRotationAnimationProto.STARTED;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.IBinder;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.Display;
@@ -268,15 +269,23 @@ class ScreenRotationAnimation {
                    .build();

            // capture a screenshot into the surface we just created
            // TODO(multidisplay): we should use the proper display
            final int displayId = SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN;
            final IBinder displayHandle = SurfaceControl.getBuiltInDisplay(displayId);
            // This null check below is to guard a race condition where WMS didn't have a chance to
            // respond to display disconnection before handling rotation , that surfaceflinger may
            // return a null handle here because it doesn't think that display is valid anymore.
            if (displayHandle != null) {
                Surface sur = new Surface();
                sur.copyFrom(mSurfaceControl);
            // TODO(multidisplay): we should use the proper display
            SurfaceControl.screenshot(SurfaceControl.getBuiltInDisplay(
                            SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN), sur);
                SurfaceControl.screenshot(displayHandle, sur);
                t.setLayer(mSurfaceControl, SCREEN_FREEZE_LAYER_SCREENSHOT);
                t.setAlpha(mSurfaceControl, 0);
                t.show(mSurfaceControl);
                sur.destroy();
            } else {
                Slog.w(TAG, "Built-in display " + displayId + " is null.");
            }
        } catch (OutOfResourcesException e) {
            Slog.w(TAG, "Unable to allocate freeze surface", e);
        }