diff --git a/quickstep/src/com/android/launcher3/model/WidgetPredictionsRequester.java b/quickstep/src/com/android/launcher3/model/WidgetPredictionsRequester.java index 41fcf61d81..8c98babc0a 100644 --- a/quickstep/src/com/android/launcher3/model/WidgetPredictionsRequester.java +++ b/quickstep/src/com/android/launcher3/model/WidgetPredictionsRequester.java @@ -59,6 +59,11 @@ import java.util.stream.Collectors; public class WidgetPredictionsRequester { private static final int NUM_OF_RECOMMENDED_WIDGETS_PREDICATION = 20; private static final String BUNDLE_KEY_ADDED_APP_WIDGETS = "added_app_widgets"; + // container/screenid/[positionx,positiony]/[spanx,spany] + // Matches the format passed used by PredictionHelper; But, position and size values aren't + // used, so, we pass default values. + @VisibleForTesting + static final String LAUNCH_LOCATION = "workspace/1/[0,0]/[2,2]"; @Nullable private AppPredictor mAppPredictor; @@ -86,7 +91,7 @@ public class WidgetPredictionsRequester { */ public void request(List existingWidgets, Consumer> callback) { - Bundle bundle = buildBundleForPredictionSession(existingWidgets, mUiSurface); + Bundle bundle = buildBundleForPredictionSession(existingWidgets); Predicate filter = notOnUiSurfaceFilter(existingWidgets); MODEL_EXECUTOR.execute(() -> { @@ -112,17 +117,14 @@ public class WidgetPredictionsRequester { * Returns a bundle that can be passed in a prediction session * * @param addedWidgets widgets that are already added by the user in the ui surface - * @param uiSurface a unique identifier of the surface hosting widgets; format - * "widgets_xx"; note - "widgets" is reserved for home screen surface. */ @VisibleForTesting - static Bundle buildBundleForPredictionSession(List addedWidgets, - String uiSurface) { + static Bundle buildBundleForPredictionSession(List addedWidgets) { Bundle bundle = new Bundle(); ArrayList addedAppTargetEvents = new ArrayList<>(); for (AppWidgetProviderInfo info : addedWidgets) { ComponentName componentName = info.provider; - AppTargetEvent appTargetEvent = buildAppTargetEvent(uiSurface, info, componentName); + AppTargetEvent appTargetEvent = buildAppTargetEvent(info, componentName); addedAppTargetEvents.add(appTargetEvent); } bundle.putParcelableArrayList(BUNDLE_KEY_ADDED_APP_WIDGETS, addedAppTargetEvents); @@ -134,13 +136,13 @@ public class WidgetPredictionsRequester { * predictor. * Also see {@link PredictionHelper} */ - private static AppTargetEvent buildAppTargetEvent(String uiSurface, AppWidgetProviderInfo info, + private static AppTargetEvent buildAppTargetEvent(AppWidgetProviderInfo info, ComponentName componentName) { AppTargetId appTargetId = new AppTargetId("widget:" + componentName.getPackageName()); AppTarget appTarget = new AppTarget.Builder(appTargetId, componentName.getPackageName(), /*user=*/ info.getProfile()).setClassName(componentName.getClassName()).build(); - return new AppTargetEvent.Builder(appTarget, AppTargetEvent.ACTION_PIN) - .setLaunchLocation(uiSurface).build(); + return new AppTargetEvent.Builder(appTarget, AppTargetEvent.ACTION_PIN).setLaunchLocation( + LAUNCH_LOCATION).build(); } /** diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/model/WidgetsPredictionsRequesterTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/model/WidgetsPredictionsRequesterTest.kt index 039dce4393..4ea74df776 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/model/WidgetsPredictionsRequesterTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/model/WidgetsPredictionsRequesterTest.kt @@ -30,6 +30,7 @@ import com.android.launcher3.DeviceProfile import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.LauncherAppState import com.android.launcher3.icons.IconCache +import com.android.launcher3.model.WidgetPredictionsRequester.LAUNCH_LOCATION import com.android.launcher3.model.WidgetPredictionsRequester.buildBundleForPredictionSession import com.android.launcher3.model.WidgetPredictionsRequester.filterPredictions import com.android.launcher3.model.WidgetPredictionsRequester.notOnUiSurfaceFilter @@ -103,7 +104,7 @@ class WidgetsPredictionsRequesterTest { fun buildBundleForPredictionSession_includesAddedAppWidgets() { val existingWidgets = arrayListOf(widget1aInfo, widget1bInfo, widget2Info) - val bundle = buildBundleForPredictionSession(existingWidgets, TEST_UI_SURFACE) + val bundle = buildBundleForPredictionSession(existingWidgets) val addedWidgetsBundleExtra = bundle.getParcelableArrayList(BUNDLE_KEY_ADDED_APP_WIDGETS, AppTarget::class.java) @@ -213,7 +214,7 @@ class WidgetsPredictionsRequesterTest { .setClassName(providerClassName) .build() return AppTargetEvent.Builder(appTarget, AppTargetEvent.ACTION_PIN) - .setLaunchLocation(TEST_UI_SURFACE) + .setLaunchLocation(LAUNCH_LOCATION) .build() } }