From 20a5f4e8d12583c3fb414ec052e13a182ba3181b Mon Sep 17 00:00:00 2001 From: Shamali P Date: Tue, 5 Mar 2024 16:01:05 +0000 Subject: [PATCH] Update labels for the categories to match the UX writer provided strings Also fix issue that user was not passed when getting application info. (error noticed by Zak) http://screen/8fiiTSHvo2SfYdE Bug: 318410881 Flag: N/A Test: Unit test Change-Id: Id85feec0d95d3d4d183a673f7eed40906b0043e2 --- .../WidgetsPredicationUpdateTaskTest.java | 20 +++++-- res/values/strings.xml | 12 ++-- .../WidgetRecommendationCategoryProvider.java | 33 +++++----- ...getRecommendationCategoryProviderTest.java | 60 ++++++++++++------- 4 files changed, 79 insertions(+), 46 deletions(-) diff --git a/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java b/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java index 37dde10d0e..8702f70dfe 100644 --- a/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java +++ b/quickstep/tests/src/com/android/launcher3/model/WidgetsPredicationUpdateTaskTest.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.model; +import static android.content.pm.ApplicationInfo.CATEGORY_PRODUCTIVITY; +import static android.content.pm.ApplicationInfo.FLAG_INSTALLED; import static android.os.Process.myUserHandle; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION; @@ -37,6 +39,8 @@ import android.app.prediction.AppTargetId; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; +import android.content.pm.ApplicationInfo; +import android.content.pm.LauncherApps; import android.os.UserHandle; import android.platform.test.flag.junit.SetFlagsRule; import android.text.TextUtils; @@ -81,6 +85,8 @@ public final class WidgetsPredicationUpdateTaskTest { private FakeBgDataModelCallback mCallback = new FakeBgDataModelCallback(); private LauncherModelHelper mModelHelper; private UserHandle mUserHandle; + private LauncherApps mLauncherApps; + @Before public void setup() throws Exception { @@ -103,12 +109,18 @@ public final class WidgetsPredicationUpdateTaskTest { allWidgets = Arrays.asList(mApp1Provider1, mApp1Provider2, mApp2Provider1, mApp4Provider1, mApp4Provider2, mApp5Provider1); + mLauncherApps = mModelHelper.sandboxContext.spyService(LauncherApps.class); doAnswer(i -> { String pkg = i.getArgument(0); - return ApplicationInfoBuilder.newBuilder().setPackageName(pkg).setName( - "App " + pkg).build(); - }).when(mModelHelper.sandboxContext.getPackageManager()) - .getApplicationInfo(anyString(), anyInt()); + ApplicationInfo applicationInfo = ApplicationInfoBuilder.newBuilder() + .setPackageName(pkg) + .setName("App " + pkg) + .build(); + applicationInfo.category = CATEGORY_PRODUCTIVITY; + applicationInfo.flags = FLAG_INSTALLED; + return applicationInfo; + }).when(mLauncherApps).getApplicationInfo(anyString(), anyInt(), any()); + AppWidgetManager manager = mModelHelper.sandboxContext.spyService(AppWidgetManager.class); doReturn(allWidgets).when(manager).getInstalledProviders(); doReturn(allWidgets).when(manager).getInstalledProvidersForProfile(eq(myUserHandle())); diff --git a/res/values/strings.xml b/res/values/strings.xml index aaef15b2af..7bf1c87830 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -75,12 +75,14 @@ Suggestions - Your Daily Essentials - News For You + Essentials + News & magazines Your Chill Zone - Reach Your Fitness Goals - Stay Ahead of the Weather - You Might Also Like + Entertainment + Social + Health & fitness + Weather + Suggested for you %1$s widgets on right, search and options on left