[a11y] Fix crash when using talkback to add to home screen.
1. Fix a crash from http://cs/android-internal/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java;l=1928;rcl=d677caa75de74f1c3a88367cad67ae405fd2903d. It can also be `ITEM_TYPE_SEARCH_ACTION`. Remove the `itemType` check and just use the `PendingAddItemInfo` class type.
2. Override `startConfigActivity` in `PinShortcutRequestActivityInfo`, so that `Launcher#onActivityResult` can be triggered properly from `Launcher#processShortcutFromDrop` (http://cs/android-internal/packages/apps/Launcher3/src/com/android/launcher3/Launcher.java;l=1939;rcl=d677caa75de74f1c3a88367cad67ae405fd2903d )
3. Then we call to `Launcher#completeAdd` -> `completeAddShortcut`. The original `info` passed to `processShortcutFromDrop` doesn’t have a `componentName` (new code), so remove the component non-null check from `completeAddShortcut`.
Bug: 287166186
Bug: 287167527
Bug: 287166771
Test: manual
Flag: N/A
Change-Id: Id3e1444de188f2d2af760f58e3d9814a2b7abd88
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7e43002..66c76ca 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1407,8 +1407,7 @@
*/
protected void completeAddShortcut(Intent data, int container, int screenId, int cellX,
int cellY, PendingRequestArgs args) {
- if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT
- || args.getPendingIntent().getComponent() == null) {
+ if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT) {
return;
}
@@ -1916,16 +1915,10 @@
info.spanX = spanX;
info.spanY = spanY;
- switch (info.itemType) {
- case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
- case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
- addAppWidgetFromDrop((PendingAddWidgetInfo) info);
- break;
- case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
- processShortcutFromDrop((PendingAddShortcutInfo) info);
- break;
- default:
- throw new IllegalStateException("Unknown item type: " + info.itemType);
+ if (info instanceof PendingAddWidgetInfo) {
+ addAppWidgetFromDrop((PendingAddWidgetInfo) info);
+ } else { // info can only be PendingAddShortcutInfo
+ processShortcutFromDrop((PendingAddShortcutInfo) info);
}
}