summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Garfield Tan <xutan@google.com> 2018-03-20 17:20:05 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-03-20 17:20:05 +0000
commit7a4a3599128478fa930b0a623130157a4def9412 (patch)
tree9a0eaf45530c7d941b55c9e41172e9327f1f4d43
parent3014a7a8c1f3bccc7d74a94d45f4d3f4e3e025a7 (diff)
parentf4ac3072460095c567580b83ae5a6800a7e540fc (diff)
Merge "Add a null check in case the display is missing." into pi-dev
-rw-r--r--services/core/java/com/android/server/wm/ScreenRotationAnimation.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
index ad2fabb70299..235f63e6fd7f 100644
--- a/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/core/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -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
- 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);
- t.setLayer(mSurfaceControl, SCREEN_FREEZE_LAYER_SCREENSHOT);
- t.setAlpha(mSurfaceControl, 0);
- t.show(mSurfaceControl);
- sur.destroy();
+ 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);
+ 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);
}