Only use FLAG_ACTIVITY_CLEAR_TOP on the search intent when from global search.
Fixes http://b/issue?id=2178591
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 8faef59ba..e5a769b 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -1646,8 +1646,11 @@
Intent intent = new Intent(action);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// We need CLEAR_TOP to avoid reusing an old task that has other activities
- // on top of the one we want.
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ // on top of the one we want. We don't want to do this in in-app search though,
+ // as it can be destructive to the activity stack.
+ if (mGlobalSearchMode) {
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ }
if (data != null) {
intent.setData(data);
}