From ac05cb134339a32c8ebf6f57412f0aac7481cc4f Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Wed, 5 May 2021 15:37:00 +0100 Subject: [PATCH] Fix class cast exception in a11y service for widget resize action Test: Enable talkback. Then navigate to a widget. Trigger talkback menu > actions > move. Able to move a widget without crash. Bug: 186999201 Change-Id: Ic6a66fefd643443e3d5a8839e6f2fe10c946dab2 --- .../accessibility/LauncherAccessibilityDelegate.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index a5852ba828..dbdfb2b663 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -32,6 +32,7 @@ import com.android.launcher3.R; import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragController.DragListener; import com.android.launcher3.dragndrop.DragOptions; +import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.folder.Folder; import com.android.launcher3.keyboard.KeyboardDragAndDropView; import com.android.launcher3.model.data.AppInfo; @@ -290,7 +291,12 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme return actions; } - CellLayout layout = (CellLayout) host.getParent().getParent(); + CellLayout layout; + if (host.getParent() instanceof DragView) { + layout = (CellLayout) ((DragView) host.getParent()).getContentViewParent().getParent(); + } else { + layout = (CellLayout) host.getParent().getParent(); + } if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) { if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) || layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {