Introduces CONTAINER_WIDGETS_TRAY to LauncherSettings.Favorites.

This would log LAUNCHER_ITEM_DRAG_STARTED event when an item is dragged from widgets tray. This also fixes empty component with widget logs.

Sample Log: https://docs.google.com/document/d/1CBP2yTcXdFhPdNG5ZmWFKSgd8mDbMevY-akVlUXPLDo/edit#bookmark=id.bk5w3n8uwhcl

Bug: 152978018
Change-Id: I51d16edae13973d5e62adda0e4efa861fa10dc1b
This commit is contained in:
thiruram 2020-05-06 22:19:43 -07:00
parent 4ae95beb9b
commit 6bf6848951
7 changed files with 53 additions and 7 deletions

View File

@ -48,12 +48,16 @@ message ContainerInfo {
HotseatContainer hotseat = 2; HotseatContainer hotseat = 2;
FolderContainer folder = 3; FolderContainer folder = 3;
AllAppsContainer all_apps_container = 4; AllAppsContainer all_apps_container = 4;
WidgetsContainer widgets_container = 5;
} }
} }
message AllAppsContainer { message AllAppsContainer {
} }
message WidgetsContainer {
}
enum Origin { enum Origin {
UNKNOWN = 0; UNKNOWN = 0;
DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat

View File

@ -153,12 +153,16 @@ public class LauncherSettings {
public static final int CONTAINER_PREDICTION = -102; public static final int CONTAINER_PREDICTION = -102;
public static final int CONTAINER_HOTSEAT_PREDICTION = -103; public static final int CONTAINER_HOTSEAT_PREDICTION = -103;
public static final int CONTAINER_ALL_APPS = -104; public static final int CONTAINER_ALL_APPS = -104;
public static final int CONTAINER_WIDGETS_TRAY = -105;
public static final String containerToString(int container) { public static final String containerToString(int container) {
switch (container) { switch (container) {
case CONTAINER_DESKTOP: return "desktop"; case CONTAINER_DESKTOP: return "desktop";
case CONTAINER_HOTSEAT: return "hotseat"; case CONTAINER_HOTSEAT: return "hotseat";
case CONTAINER_PREDICTION: return "prediction"; case CONTAINER_PREDICTION: return "prediction";
case CONTAINER_ALL_APPS: return "all_apps";
case CONTAINER_WIDGETS_TRAY: return "widgets_tray";
default: return String.valueOf(container); default: return String.valueOf(container);
} }
} }

View File

@ -18,12 +18,15 @@ package com.android.launcher3;
import android.content.ComponentName; import android.content.ComponentName;
import androidx.annotation.Nullable;
import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfo;
import java.util.Optional;
/** /**
* Meta data that is used for deferred binding. * Meta data that is used for deferred binding. e.g., this object is used to pass information on
* e.g., this object is used to pass information on draggable targets when they are dropped onto * draggable targets when they are dropped onto the workspace from another container.
* the workspace from another container.
*/ */
public class PendingAddItemInfo extends ItemInfo { public class PendingAddItemInfo extends ItemInfo {
@ -36,4 +39,22 @@ public class PendingAddItemInfo extends ItemInfo {
protected String dumpProperties() { protected String dumpProperties() {
return super.dumpProperties() + " componentName=" + componentName; return super.dumpProperties() + " componentName=" + componentName;
} }
/**
* Returns shallow copy of the object.
*/
@Override
public ItemInfo makeShallowCopy() {
PendingAddItemInfo itemInfo = new PendingAddItemInfo();
itemInfo.copyFrom(this);
itemInfo.componentName = this.componentName;
return itemInfo;
}
@Nullable
@Override
public ComponentName getTargetComponent() {
return Optional.ofNullable(super.getTargetComponent()).orElse(componentName);
}
} }

View File

@ -2438,6 +2438,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
// widgets/shortcuts/folders in a slightly different way // widgets/shortcuts/folders in a slightly different way
mLauncher.addPendingItem(pendingInfo, container, screenId, mTargetCell, mLauncher.addPendingItem(pendingInfo, container, screenId, mTargetCell,
item.spanX, item.spanY); item.spanX, item.spanY);
mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId,
d.dragInfo.buildProto(null));
} }
}; };
boolean isWidget = pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET boolean isWidget = pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
@ -2526,11 +2530,12 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, view, this); mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, view, this);
resetTransitionTransform(); resetTransitionTransform();
} }
mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId,
d.dragInfo.buildProto(null));
} }
mStatsLogManager.log(
LauncherEvent.LAUNCHER_ITEM_DROP_COMPLETED,
d.logInstanceId,
d.dragInfo.buildProto(null));
} }
public Bitmap createWidgetBitmap(ItemInfo widgetInfo, View layout) { public Bitmap createWidgetBitmap(ItemInfo widgetInfo, View layout) {

View File

@ -20,6 +20,7 @@ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APP
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
@ -342,6 +343,11 @@ public class ItemInfo {
.setAllAppsContainer( .setAllAppsContainer(
AllAppsContainer.getDefaultInstance()) AllAppsContainer.getDefaultInstance())
.build(); .build();
case CONTAINER_WIDGETS_TRAY:
return ContainerInfo.newBuilder()
.setWidgetsContainer(
LauncherAtom.WidgetsContainer.getDefaultInstance())
.build();
} }
return ContainerInfo.getDefaultInstance(); return ContainerInfo.getDefaultInstance();
} }

View File

@ -15,6 +15,8 @@
*/ */
package com.android.launcher3.widget; package com.android.launcher3.widget;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
import com.android.launcher3.PendingAddItemInfo; import com.android.launcher3.PendingAddItemInfo;
import com.android.launcher3.pm.ShortcutConfigActivityInfo; import com.android.launcher3.pm.ShortcutConfigActivityInfo;
@ -32,5 +34,6 @@ public class PendingAddShortcutInfo extends PendingAddItemInfo {
componentName = activityInfo.getComponent(); componentName = activityInfo.getComponent();
user = activityInfo.getUser(); user = activityInfo.getUser();
itemType = activityInfo.getItemType(); itemType = activityInfo.getItemType();
this.container = CONTAINER_WIDGETS_TRAY;
} }
} }

View File

@ -15,6 +15,8 @@
*/ */
package com.android.launcher3.widget; package com.android.launcher3.widget;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY;
import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetHostView;
import android.os.Bundle; import android.os.Bundle;
@ -50,6 +52,7 @@ public class PendingAddWidgetInfo extends PendingAddItemInfo {
spanY = i.spanY; spanY = i.spanY;
minSpanX = i.minSpanX; minSpanX = i.minSpanX;
minSpanY = i.minSpanY; minSpanY = i.minSpanY;
this.container = CONTAINER_WIDGETS_TRAY;
} }
public WidgetAddFlowHandler getHandler() { public WidgetAddFlowHandler getHandler() {