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

Commit 95b7e269 authored by Daichi Hirono's avatar Daichi Hirono
Browse files

Prevent NullPointerException from long tap on destroyed window decoration.

The long tap event could be delivered after the window decoration was
destroyed and removed from DesktopModeWindowDecorViewModel. This change
ensures the long tap is canceled during destruction, preventing the
listener from accessing a non-existent DesktopModeWindowDecoration.

Bug: 397767291
Test: None
Flag: com.android.window.flags.enable_desktop_windowing_mode
Change-Id: I55286357680e8ae9cfddb5e84d4a637931b28fa1
parent 81abb3be
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1697,6 +1697,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        mExclusionRegionListener.onExclusionRegionDismissed(mTaskInfo.taskId);
        disposeResizeVeil();
        disposeStatusBarInputLayer();
        mWindowDecorViewHolder.close();
        mWindowDecorViewHolder = null;
        if (canEnterDesktopMode(mContext) && isEducationEnabled()) {
            notifyNoCaptionHandle();
+2 −0
Original line number Diff line number Diff line
@@ -274,4 +274,6 @@ internal class AppHandleViewHolder(
            }
        animator.start()
    }

    override fun close() {}
}
+5 −0
Original line number Diff line number Diff line
@@ -714,6 +714,11 @@ class AppHeaderViewHolder(
                Configuration.UI_MODE_NIGHT_YES
    }

    override fun close() {
        // Should not fire long press events after closing the window decoration.
        maximizeWindowButton.cancelLongPress()
    }

    companion object {
        private const val TAG = "DesktopModeAppControlsWindowDecorationViewHolder"

+4 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import com.android.wm.shell.windowdecor.viewholder.WindowDecorationViewHolder.Da
 * Encapsulates the root [View] of a window decoration and its children to facilitate looking up
 * children (via findViewById) and updating to the latest data from [RunningTaskInfo].
 */
abstract class WindowDecorationViewHolder<T : Data>(rootView: View) {
abstract class WindowDecorationViewHolder<T : Data>(rootView: View) : AutoCloseable {
  val context: Context = rootView.context

  /**
@@ -39,6 +39,9 @@ abstract class WindowDecorationViewHolder<T : Data>(rootView: View) {
  /** Callback when the handle menu is closed. */
  abstract fun onHandleMenuClosed()

  /** Callback when the window decoration is destroyed. */
  abstract override fun close()

  /** Data clas that contains the information needed to update the view holder. */
  abstract class Data
}