Merge "Removing support for lagacy shortcuts" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e607fdb2a2
@@ -337,7 +337,6 @@ public class PredictedAppIcon extends DoubleShadowBubbleTextView {
|
||||
if (getTag() instanceof WorkspaceItemInfo) {
|
||||
WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
|
||||
isBadged = !Process.myUserHandle().equals(info.user)
|
||||
|| info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT
|
||||
|| info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import static com.android.launcher3.LauncherSettings.Animation.VIEW_BACKGROUND;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
|
||||
import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.NO_OFFSET;
|
||||
@@ -283,7 +282,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
|
||||
if (mAllAppsPredictions != null
|
||||
&& (info.itemType == ITEM_TYPE_APPLICATION
|
||||
|| info.itemType == ITEM_TYPE_SHORTCUT
|
||||
|| info.itemType == ITEM_TYPE_DEEP_SHORTCUT)) {
|
||||
int count = mAllAppsPredictions.items.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
@@ -1162,7 +1160,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
}
|
||||
switch (info.itemType) {
|
||||
case Favorites.ITEM_TYPE_APPLICATION:
|
||||
case Favorites.ITEM_TYPE_SHORTCUT:
|
||||
case Favorites.ITEM_TYPE_DEEP_SHORTCUT:
|
||||
case Favorites.ITEM_TYPE_APPWIDGET:
|
||||
// Fall through and continue if it's an app, shortcut, or widget
|
||||
|
||||
+67
-75
@@ -20,6 +20,7 @@ import static android.os.Process.myUserHandle;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.util.TestUtil.runOnExecutorSync;
|
||||
import static com.android.launcher3.util.WidgetUtils.createAppWidgetProviderInfo;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -40,11 +41,9 @@ import android.text.TextUtils;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.icons.ComponentWithLabel;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
|
||||
import com.android.launcher3.model.QuickstepModelDelegate.PredictorState;
|
||||
import com.android.launcher3.util.LauncherLayoutBuilder;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.widget.PendingAddWidgetInfo;
|
||||
@@ -53,8 +52,6 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -76,17 +73,9 @@ public final class WidgetsPredicationUpdateTaskTest {
|
||||
private LauncherModelHelper mModelHelper;
|
||||
private UserHandle mUserHandle;
|
||||
|
||||
@Mock
|
||||
private IconCache mIconCache;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
mModelHelper = new LauncherModelHelper();
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doAnswer(invocation -> {
|
||||
ComponentWithLabel componentWithLabel = invocation.getArgument(0);
|
||||
return componentWithLabel.getComponent().getShortClassName();
|
||||
}).when(mIconCache).getTitleNoCache(any());
|
||||
|
||||
mUserHandle = myUserHandle();
|
||||
mApp1Provider1 = createAppWidgetProviderInfo(
|
||||
@@ -114,16 +103,12 @@ public final class WidgetsPredicationUpdateTaskTest {
|
||||
.collect(Collectors.toList());
|
||||
}).when(manager).getInstalledProvidersForPackage(any(), eq(myUserHandle()));
|
||||
|
||||
// 2 widgets, app4/provider1 & app5/provider1, have already been added to the workspace.
|
||||
mModelHelper.initializeData("widgets_predication_update_task_data");
|
||||
|
||||
LauncherLayoutBuilder builder = new LauncherLayoutBuilder()
|
||||
.atWorkspace(0, 1, 2).putWidget("app4", "provider1", 1, 1)
|
||||
.atWorkspace(0, 1, 3).putWidget("app5", "provider1", 1, 1);
|
||||
mModelHelper.setupDefaultLayoutProvider(builder);
|
||||
MAIN_EXECUTOR.submit(() -> mModelHelper.getModel().addCallbacks(mCallback)).get();
|
||||
MODEL_EXECUTOR.post(() -> mModelHelper.getBgDataModel().widgetsModel.update(
|
||||
LauncherAppState.getInstance(mModelHelper.sandboxContext),
|
||||
/* packageUser= */ null));
|
||||
|
||||
MODEL_EXECUTOR.submit(() -> { }).get();
|
||||
MAIN_EXECUTOR.submit(() -> { }).get();
|
||||
mModelHelper.loadModelSync();
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -132,65 +117,72 @@ public final class WidgetsPredicationUpdateTaskTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void widgetsRecommendationRan_shouldOnlyReturnNotAddedWidgetsInAppPredictionOrder()
|
||||
throws Exception {
|
||||
// WHEN newPredicationTask is executed with app predication of 5 apps.
|
||||
AppTarget app1 = new AppTarget(new AppTargetId("app1"), "app1", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget app2 = new AppTarget(new AppTargetId("app2"), "app2", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget app3 = new AppTarget(new AppTargetId("app3"), "app3", "className",
|
||||
mUserHandle);
|
||||
AppTarget app4 = new AppTarget(new AppTargetId("app4"), "app4", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget app5 = new AppTarget(new AppTargetId("app5"), "app5", "provider1",
|
||||
mUserHandle);
|
||||
mModelHelper.executeTaskForTest(
|
||||
newWidgetsPredicationTask(List.of(app5, app3, app2, app4, app1)))
|
||||
.forEach(Runnable::run);
|
||||
public void widgetsRecommendationRan_shouldOnlyReturnNotAddedWidgetsInAppPredictionOrder() {
|
||||
// Run on model executor so that no other task runs in the middle.
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
// WHEN newPredicationTask is executed with app predication of 5 apps.
|
||||
AppTarget app1 = new AppTarget(new AppTargetId("app1"), "app1", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget app2 = new AppTarget(new AppTargetId("app2"), "app2", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget app3 = new AppTarget(new AppTargetId("app3"), "app3", "className",
|
||||
mUserHandle);
|
||||
AppTarget app4 = new AppTarget(new AppTargetId("app4"), "app4", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget app5 = new AppTarget(new AppTargetId("app5"), "app5", "provider1",
|
||||
mUserHandle);
|
||||
mCallback.mRecommendedWidgets = null;
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(
|
||||
newWidgetsPredicationTask(List.of(app5, app3, app2, app4, app1)));
|
||||
runOnExecutorSync(MAIN_EXECUTOR, () -> { });
|
||||
|
||||
// THEN only 2 widgets are returned because
|
||||
// 1. app5/provider1 & app4/provider1 have already been added to workspace. They are
|
||||
// excluded from the result.
|
||||
// 2. app3 doesn't have a widget.
|
||||
// 3. only 1 widget is picked from app1 because we only want to promote one widget per app.
|
||||
List<PendingAddWidgetInfo> recommendedWidgets = mCallback.mRecommendedWidgets.items
|
||||
.stream()
|
||||
.map(itemInfo -> (PendingAddWidgetInfo) itemInfo)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(recommendedWidgets).hasSize(2);
|
||||
assertWidgetInfo(recommendedWidgets.get(0).info, mApp2Provider1);
|
||||
assertWidgetInfo(recommendedWidgets.get(1).info, mApp1Provider1);
|
||||
// THEN only 2 widgets are returned because
|
||||
// 1. app5/provider1 & app4/provider1 have already been added to workspace. They are
|
||||
// excluded from the result.
|
||||
// 2. app3 doesn't have a widget.
|
||||
// 3. only 1 widget is picked from app1 because we only want to promote one widget per app.
|
||||
List<PendingAddWidgetInfo> recommendedWidgets = mCallback.mRecommendedWidgets.items
|
||||
.stream()
|
||||
.map(itemInfo -> (PendingAddWidgetInfo) itemInfo)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(recommendedWidgets).hasSize(2);
|
||||
assertWidgetInfo(recommendedWidgets.get(0).info, mApp2Provider1);
|
||||
assertWidgetInfo(recommendedWidgets.get(1).info, mApp1Provider1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void widgetsRecommendationRan_shouldReturnPackageWidgetsWhenEmpty()
|
||||
throws Exception {
|
||||
public void widgetsRecommendationRan_shouldReturnPackageWidgetsWhenEmpty() {
|
||||
runOnExecutorSync(MODEL_EXECUTOR, () -> {
|
||||
|
||||
// Not installed widget
|
||||
AppTarget widget1 = new AppTarget(new AppTargetId("app1"), "app1", "provider3",
|
||||
mUserHandle);
|
||||
// Not installed app
|
||||
AppTarget widget3 = new AppTarget(new AppTargetId("app2"), "app3", "provider1",
|
||||
mUserHandle);
|
||||
// Workspace added widgets
|
||||
AppTarget widget4 = new AppTarget(new AppTargetId("app4"), "app4", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget widget5 = new AppTarget(new AppTargetId("app5"), "app5", "provider1",
|
||||
mUserHandle);
|
||||
mModelHelper.executeTaskForTest(
|
||||
newWidgetsPredicationTask(List.of(widget5, widget3, widget4, widget1)))
|
||||
.forEach(Runnable::run);
|
||||
// Not installed widget
|
||||
AppTarget widget1 = new AppTarget(new AppTargetId("app1"), "app1", "provider3",
|
||||
mUserHandle);
|
||||
// Not installed app
|
||||
AppTarget widget3 = new AppTarget(new AppTargetId("app2"), "app3", "provider1",
|
||||
mUserHandle);
|
||||
// Workspace added widgets
|
||||
AppTarget widget4 = new AppTarget(new AppTargetId("app4"), "app4", "provider1",
|
||||
mUserHandle);
|
||||
AppTarget widget5 = new AppTarget(new AppTargetId("app5"), "app5", "provider1",
|
||||
mUserHandle);
|
||||
|
||||
// THEN only 2 widgets are returned because the launcher only filters out non-exist widgets.
|
||||
List<PendingAddWidgetInfo> recommendedWidgets = mCallback.mRecommendedWidgets.items
|
||||
.stream()
|
||||
.map(itemInfo -> (PendingAddWidgetInfo) itemInfo)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(recommendedWidgets).hasSize(2);
|
||||
// Another widget from the same package
|
||||
assertWidgetInfo(recommendedWidgets.get(0).info, mApp4Provider2);
|
||||
assertWidgetInfo(recommendedWidgets.get(1).info, mApp1Provider1);
|
||||
mCallback.mRecommendedWidgets = null;
|
||||
mModelHelper.getModel().enqueueModelUpdateTask(
|
||||
newWidgetsPredicationTask(List.of(widget5, widget3, widget4, widget1)));
|
||||
runOnExecutorSync(MAIN_EXECUTOR, () -> { });
|
||||
|
||||
// THEN only 2 widgets are returned because the launcher only filters out
|
||||
// non-exist widgets.
|
||||
List<PendingAddWidgetInfo> recommendedWidgets = mCallback.mRecommendedWidgets.items
|
||||
.stream()
|
||||
.map(itemInfo -> (PendingAddWidgetInfo) itemInfo)
|
||||
.collect(Collectors.toList());
|
||||
assertThat(recommendedWidgets).hasSize(2);
|
||||
// Another widget from the same package
|
||||
assertWidgetInfo(recommendedWidgets.get(0).info, mApp4Provider2);
|
||||
assertWidgetInfo(recommendedWidgets.get(1).info, mApp1Provider1);
|
||||
});
|
||||
}
|
||||
|
||||
private void assertWidgetInfo(
|
||||
|
||||
Reference in New Issue
Block a user