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

Commit 72cdc50a authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Preventing NPE crash if view is detached from window.

View#getDisplay can return null if the view is detached from window.
Get the display by Context#getDisplay should ensure there can always
return the local display object.

Bug: 235283631
Test: enable shell transition, repeatly run AppConfigurationTests
testConfigurationUpdatesWhenRotatingWhileFullscreen and verify no crash
in system ui.

Change-Id: I792417a55a588c9552529f2815c1ab5d88f427e7
Merged-In: I792417a55a588c9552529f2815c1ab5d88f427e7
(cherry picked from commit e4f2b2c0)
parent 2b868683
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -87,20 +87,21 @@ open class DisplayCutoutBaseView : View, RegionInterceptableView {

    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()