Merge "Preventing NPE crash if view is detached from window." into tm-dev am: 76386f47a4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18799295
Change-Id: I134b98555059d3e17b75797b9172bcd172d90671
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/packages/SystemUI/src/com/android/systemui/DisplayCutoutBaseView.kt b/packages/SystemUI/src/com/android/systemui/DisplayCutoutBaseView.kt
index 8ab1ab7..34164f3 100644
--- a/packages/SystemUI/src/com/android/systemui/DisplayCutoutBaseView.kt
+++ b/packages/SystemUI/src/com/android/systemui/DisplayCutoutBaseView.kt
@@ -87,20 +87,21 @@
fun onDisplayChanged(displayId: Int) {
val oldMode: Display.Mode? = displayMode
- displayMode = display.mode
+ val display: Display? = context.display
+ displayMode = display?.mode
- if (displayUniqueId != context.display?.uniqueId) {
- displayUniqueId = context.display?.uniqueId
+ if (displayUniqueId != display?.uniqueId) {
+ displayUniqueId = display?.uniqueId
shouldDrawCutout = DisplayCutout.getFillBuiltInDisplayCutout(
context.resources, displayUniqueId)
}
// Skip if display mode or cutout hasn't changed.
if (!displayModeChanged(oldMode, displayMode) &&
- display.cutout == displayInfo.displayCutout) {
+ display?.cutout == displayInfo.displayCutout) {
return
}
- if (displayId == display.displayId) {
+ if (displayId == display?.displayId) {
updateCutout()
updateProtectionBoundingPath()
onUpdate()