diff --git a/api/current.txt b/api/current.txt
index 76f2cd47b0e87..be9b3c3b32b69 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5312,6 +5312,7 @@ package android.appwidget {
field public static final int RESIZE_VERTICAL = 2; // 0x2
field public static final int WIDGET_CATEGORY_HOME_SCREEN = 1; // 0x1
field public static final int WIDGET_CATEGORY_KEYGUARD = 2; // 0x2
+ field public static final int WIDGET_CATEGORY_RECENTS = 4; // 0x4
field public int autoAdvanceViewId;
field public android.content.ComponentName configure;
field public int icon;
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index dd3a871a2def6..d3e908948e2b6 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -181,7 +181,8 @@ public class AppWidgetManager {
* A bundle extra that hints to the AppWidgetProvider the category of host that owns this
* this widget. Can have the value {@link
* AppWidgetProviderInfo#WIDGET_CATEGORY_HOME_SCREEN} or {@link
- * AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD}.
+ * AppWidgetProviderInfo#WIDGET_CATEGORY_KEYGUARD} or {@link
+ * AppWidgetProviderInfo#WIDGET_CATEGORY_RECENTS}.
*/
public static final String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory";
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index 8670da776885c..8b9c7f0f5d7d0 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -55,7 +55,6 @@ public class AppWidgetProviderInfo implements Parcelable {
/**
* Indicates that the widget can be displayed within recents.
- * @hide
*/
public static final int WIDGET_CATEGORY_RECENTS = 4;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 156276b77d168..0326e18ce5aca 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5956,11 +5956,12 @@
+ ie. home screen, keyguard, recents or any combination thereof.
+ Supports combined values using | operator. -->
+
diff --git a/packages/SystemUI/res/values-sw720dp/config.xml b/packages/SystemUI/res/values-sw720dp/config.xml
index bf01a8d5ae5da..7cf711a45b736 100644
--- a/packages/SystemUI/res/values-sw720dp/config.xml
+++ b/packages/SystemUI/res/values-sw720dp/config.xml
@@ -32,5 +32,8 @@
0
+
+
+ false
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 024f1ebf79a44..c3ccb59c40289 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -123,6 +123,8 @@
150
96
+
+ true
true
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 5a1dc8d01d15d..23a01790b186e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -37,6 +37,7 @@ public class RecentsConfiguration {
public Rect displayRect = new Rect();
boolean isLandscape;
+ boolean transposeSearchLayoutWithOrientation;
int searchBarAppWidgetId = -1;
public float animationPxMovementPerSecond;
@@ -83,6 +84,8 @@ public class RecentsConfiguration {
isLandscape = res.getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
+ transposeSearchLayoutWithOrientation =
+ res.getBoolean(R.bool.recents_transpose_search_layout_with_orientation);
Console.log(Constants.DebugFlags.UI.MeasureAndLayout,
"[RecentsConfiguration|orientation]", isLandscape ? "Landscape" : "Portrait",
Console.AnsiGreen);
@@ -148,7 +151,7 @@ public class RecentsConfiguration {
if (hasSearchBarAppWidget()) {
Rect searchBarBounds = new Rect();
getSearchBarBounds(width, height, searchBarBounds);
- if (isLandscape) {
+ if (isLandscape && transposeSearchLayoutWithOrientation) {
// In landscape, the search bar appears on the left, so shift the task rect right
taskStackBounds.set(searchBarBounds.width(), 0, width, height);
} else {
@@ -171,7 +174,7 @@ public class RecentsConfiguration {
return;
}
- if (isLandscape) {
+ if (isLandscape && transposeSearchLayoutWithOrientation) {
// In landscape, the search bar appears on the left
searchBarSpaceBounds.set(0, 0, searchBarSpaceHeightPx, height);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
index 68af6635ce7b5..c3b8a20743ca5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
@@ -55,6 +55,7 @@ public class SystemServicesProxy {
UserManager mUm;
SearchManager mSm;
String mPackage;
+ ComponentName mAssistComponent;
Bitmap mDummyIcon;
@@ -68,6 +69,12 @@ public class SystemServicesProxy {
mSm = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
mPackage = context.getPackageName();
+ // Resolve the assist intent
+ Intent assist = mSm.getAssistIntent(context, false);
+ if (assist != null) {
+ mAssistComponent = assist.getComponent();
+ }
+
if (Constants.DebugFlags.App.EnableSystemServicesProxy) {
// Create a dummy icon
mDummyIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
@@ -236,30 +243,14 @@ public class SystemServicesProxy {
*/
public Pair bindSearchAppWidget(AppWidgetHost host) {
if (mAwm == null) return null;
+ if (mAssistComponent == null) return null;
- // Ensure we have a global search activity
- ComponentName globalSearchActivity = mSm.getGlobalSearchActivity();
- if (globalSearchActivity == null) return null;
-
- // Resolve the search widget provider from the search activity
- ActivityInfo searchActivityInfo = getActivityInfo(globalSearchActivity);
- if (searchActivityInfo == null) return null;
-
- String key = "com.android.recents.search_widget_provider";
- ComponentName searchWidgetCn = null;
- Bundle searchMetaData = searchActivityInfo.metaData;
- String searchWidgetProvider = searchMetaData.getString(key, "");
- if (searchWidgetProvider.length() != 0) {
- searchWidgetCn = ComponentName.unflattenFromString(searchWidgetProvider);
- } else {
- return null;
- }
-
- // Find the first Recents widget from the same package as the global search activity
- List widgets = mAwm.getInstalledProviders();
+ // Find the first Recents widget from the same package as the global assist activity
+ List widgets = mAwm.getInstalledProviders(
+ AppWidgetProviderInfo.WIDGET_CATEGORY_RECENTS);
AppWidgetProviderInfo searchWidgetInfo = null;
for (AppWidgetProviderInfo info : widgets) {
- if (info.provider.equals(searchWidgetCn)) {
+ if (info.provider.getPackageName().equals(mAssistComponent.getPackageName())) {
searchWidgetInfo = info;
break;
}