From 5881b910e92d63ea1bf72e81d9bdde74a494f3b4 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Fri, 2 Jul 2021 19:13:28 +0000 Subject: [PATCH] Revert "Don't use ProxyActivity when launching from SearchActionItemInfo intent" This reverts commit 878dedfb842f7a58b7e06a8ddf5060a2520a4638. Reason for revert: b/192558017 Bug: 192558017 Change-Id: I41e64ab74c00d7b255be6f3ef1b783c01571d641 --- .../launcher3/model/data/SearchActionItemInfo.java | 9 ++------- src/com/android/launcher3/touch/ItemClickHandler.java | 9 ++++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher3/model/data/SearchActionItemInfo.java b/src/com/android/launcher3/model/data/SearchActionItemInfo.java index 7ca283ee0c..b3057d5bd2 100644 --- a/src/com/android/launcher3/model/data/SearchActionItemInfo.java +++ b/src/com/android/launcher3/model/data/SearchActionItemInfo.java @@ -25,7 +25,6 @@ import android.os.UserHandle; import androidx.annotation.Nullable; -import com.android.launcher3.Utilities; import com.android.launcher3.logger.LauncherAtom.ItemInfo; import com.android.launcher3.logger.LauncherAtom.SearchActionItem; @@ -35,7 +34,6 @@ import com.android.launcher3.logger.LauncherAtom.SearchActionItem; public class SearchActionItemInfo extends ItemInfoWithIcon { public static final int FLAG_SHOULD_START = 1 << 1; - @Deprecated public static final int FLAG_SHOULD_START_FOR_RESULT = FLAG_SHOULD_START | 1 << 2; public static final int FLAG_BADGE_WITH_PACKAGE = 1 << 3; public static final int FLAG_PRIMARY_ICON_FROM_TITLE = 1 << 4; @@ -91,13 +89,10 @@ public class SearchActionItemInfo extends ItemInfoWithIcon { * Setter for mIntent with assertion for null value mPendingIntent */ public void setIntent(Intent intent) { - if (mPendingIntent != null && intent != null && Utilities.IS_DEBUG_DEVICE) { + if (mPendingIntent != null && intent != null) { throw new RuntimeException( "SearchActionItemInfo can only have either an Intent or a PendingIntent"); } - if (intent != null) { - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - } mIntent = intent; } @@ -109,7 +104,7 @@ public class SearchActionItemInfo extends ItemInfoWithIcon { * Setter of mPendingIntent with assertion for null value mIntent */ public void setPendingIntent(PendingIntent pendingIntent) { - if (mIntent != null && pendingIntent != null && Utilities.IS_DEBUG_DEVICE) { + if (mIntent != null && pendingIntent != null) { throw new RuntimeException( "SearchActionItemInfo can only have either an Intent or a PendingIntent"); } diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 408ba28e0a..b53f96eea3 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -262,12 +262,19 @@ public class ItemClickHandler { */ public static void onClickSearchAction(Launcher launcher, SearchActionItemInfo itemInfo) { if (itemInfo.getIntent() != null) { - launcher.startActivity(itemInfo.getIntent()); + if (itemInfo.hasFlags(SearchActionItemInfo.FLAG_SHOULD_START_FOR_RESULT)) { + launcher.startActivityForResult(itemInfo.getIntent(), 0); + } else { + launcher.startActivity(itemInfo.getIntent()); + } } else if (itemInfo.getPendingIntent() != null) { try { PendingIntent pendingIntent = itemInfo.getPendingIntent(); if (!itemInfo.hasFlags(SearchActionItemInfo.FLAG_SHOULD_START)) { pendingIntent.send(); + } else if (itemInfo.hasFlags(SearchActionItemInfo.FLAG_SHOULD_START_FOR_RESULT)) { + launcher.startIntentSenderForResult(pendingIntent.getIntentSender(), 0, null, 0, + 0, 0); } else { launcher.startIntentSender(pendingIntent.getIntentSender(), null, 0, 0, 0); }