Merge "Fix the NPE crash when device reboot with hide cutout set" into tm-qpr-dev
This commit is contained in:
@@ -64,8 +64,8 @@ class HideDisplayCutoutOrganizer extends DisplayAreaOrganizer {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final Rect mCurrentDisplayBounds = new Rect();
|
final Rect mCurrentDisplayBounds = new Rect();
|
||||||
// The default display cutout in natural orientation.
|
// The default display cutout in natural orientation.
|
||||||
private Insets mDefaultCutoutInsets;
|
private Insets mDefaultCutoutInsets = Insets.NONE;
|
||||||
private Insets mCurrentCutoutInsets;
|
private Insets mCurrentCutoutInsets = Insets.NONE;
|
||||||
private boolean mIsDefaultPortrait;
|
private boolean mIsDefaultPortrait;
|
||||||
private int mStatusBarHeight;
|
private int mStatusBarHeight;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -77,28 +77,36 @@ class HideDisplayCutoutOrganizer extends DisplayAreaOrganizer {
|
|||||||
|
|
||||||
private final DisplayController.OnDisplaysChangedListener mListener =
|
private final DisplayController.OnDisplaysChangedListener mListener =
|
||||||
new DisplayController.OnDisplaysChangedListener() {
|
new DisplayController.OnDisplaysChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onDisplayAdded(int displayId) {
|
||||||
|
onDisplayChanged(displayId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
|
public void onDisplayConfigurationChanged(int displayId, Configuration newConfig) {
|
||||||
if (displayId != DEFAULT_DISPLAY) {
|
onDisplayChanged(displayId);
|
||||||
return;
|
|
||||||
}
|
|
||||||
DisplayLayout displayLayout =
|
|
||||||
mDisplayController.getDisplayLayout(DEFAULT_DISPLAY);
|
|
||||||
if (displayLayout == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final boolean rotationChanged = mRotation != displayLayout.rotation();
|
|
||||||
mRotation = displayLayout.rotation();
|
|
||||||
if (rotationChanged || isDisplayBoundsChanged()) {
|
|
||||||
updateBoundsAndOffsets(true /* enabled */);
|
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
|
||||||
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
|
||||||
applyAllBoundsAndOffsets(wct, t);
|
|
||||||
applyTransaction(wct, t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void onDisplayChanged(int displayId) {
|
||||||
|
if (displayId != DEFAULT_DISPLAY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(DEFAULT_DISPLAY);
|
||||||
|
if (displayLayout == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final boolean rotationChanged = mRotation != displayLayout.rotation();
|
||||||
|
mRotation = displayLayout.rotation();
|
||||||
|
if (rotationChanged || isDisplayBoundsChanged()) {
|
||||||
|
updateBoundsAndOffsets(true /* enabled */);
|
||||||
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
|
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||||
|
applyAllBoundsAndOffsets(wct, t);
|
||||||
|
applyTransaction(wct, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HideDisplayCutoutOrganizer(Context context, DisplayController displayController,
|
HideDisplayCutoutOrganizer(Context context, DisplayController displayController,
|
||||||
ShellExecutor mainExecutor) {
|
ShellExecutor mainExecutor) {
|
||||||
super(mainExecutor);
|
super(mainExecutor);
|
||||||
|
|||||||
Reference in New Issue
Block a user