Merge changes from topic "widget-logging" into ub-launcher3-rvc-dev
* changes: Fixes missing components info when logging Widget item. Implement LAUNCHER_ITEM_DRAG_STARTED event.
This commit is contained in:
committed by
Android (Google) Code Review
commit
7a87f953a8
@@ -25,7 +25,7 @@ message ItemInfo {
|
||||
Application application = 1;
|
||||
Task task = 2;
|
||||
Shortcut shortcut = 3;
|
||||
Widget widget = 4;
|
||||
Widget widget = 4;
|
||||
}
|
||||
// When used for launch event, stores the global predictive rank
|
||||
optional int32 rank = 5;
|
||||
|
||||
@@ -56,11 +56,6 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
sContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(LauncherEvent eventId, LauncherAtom.ItemInfo item) {
|
||||
// Call StatsLog method
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify() {
|
||||
if (!(StatsLogUtils.LAUNCHER_STATE_ALLAPPS == ALLAPPS
|
||||
@@ -88,17 +83,17 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
ArrayList<LauncherAppWidgetInfo> appWidgets = (ArrayList) dataModel.appWidgets.clone();
|
||||
|
||||
for (ItemInfo info : workspaceItems) {
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null, null);
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null);
|
||||
// call StatsLog method
|
||||
}
|
||||
for (FolderInfo fInfo : folders) {
|
||||
for (ItemInfo info : fInfo.contents) {
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null, fInfo);
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(fInfo);
|
||||
// call StatsLog method
|
||||
}
|
||||
}
|
||||
for (ItemInfo info : appWidgets) {
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null, null);
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null);
|
||||
// call StatsLog method
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
getUserEventDispatcher().logAppLaunch(v, intent, user);
|
||||
|
||||
getStatsLogManager().log(APP_LAUNCH_TAP, item == null ? null
|
||||
: item.buildProto(null, null));
|
||||
: item.buildProto(null));
|
||||
return true;
|
||||
} catch (NullPointerException|ActivityNotFoundException|SecurityException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -79,6 +79,8 @@ import com.android.launcher3.folder.PreviewBackground;
|
||||
import com.android.launcher3.graphics.DragPreviewProvider;
|
||||
import com.android.launcher3.graphics.PreloadIconDrawable;
|
||||
import com.android.launcher3.icons.BitmapRenderer;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.model.data.AppInfo;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
@@ -409,6 +411,10 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
// Always enter the spring loaded mode
|
||||
mLauncher.getStateManager().goToState(SPRING_LOADED);
|
||||
StatsLogManager.newInstance(getContext())
|
||||
.log(
|
||||
LauncherEvent.LAUNCHER_ITEM_DRAG_STARTED,
|
||||
dragObject.originalDragInfo.buildProto(null));
|
||||
}
|
||||
|
||||
public void deferRemoveExtraEmptyScreen() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.launcher3.logging;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
@@ -28,6 +29,8 @@ import com.android.launcher3.util.ResourceBasedOverride;
|
||||
*/
|
||||
public class StatsLogManager implements ResourceBasedOverride {
|
||||
|
||||
private static final String TAG = "StatsLogManager";
|
||||
|
||||
interface EventEnum {
|
||||
int getId();
|
||||
}
|
||||
@@ -40,7 +43,9 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
@LauncherUiEvent(doc = "Task launched from overview using SWIPE DOWN")
|
||||
TASK_LAUNCH_SWIPE_DOWN(2),
|
||||
@LauncherUiEvent(doc = "TASK dismissed from overview using SWIPE UP")
|
||||
TASK_DISMISS_SWIPE_UP(3);
|
||||
TASK_DISMISS_SWIPE_UP(3),
|
||||
@LauncherUiEvent(doc = "User dragged a launcher item")
|
||||
LAUNCHER_ITEM_DRAG_STARTED(383);
|
||||
// ADD MORE
|
||||
|
||||
private final int mId;
|
||||
@@ -54,6 +59,13 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
|
||||
protected LogStateProvider mStateProvider;
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link StatsLogManager} based on provided context.
|
||||
*/
|
||||
public static StatsLogManager newInstance(Context context) {
|
||||
return newInstance(context, null);
|
||||
}
|
||||
|
||||
public static StatsLogManager newInstance(Context context, LogStateProvider stateProvider) {
|
||||
StatsLogManager mgr = Overrides.getObject(StatsLogManager.class,
|
||||
context.getApplicationContext(), R.string.stats_log_manager_class);
|
||||
@@ -65,7 +77,10 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
/**
|
||||
* Logs an event and accompanying {@link ItemInfo}
|
||||
*/
|
||||
public void log(LauncherEvent eventId, LauncherAtom.ItemInfo itemInfo) { }
|
||||
public void log(LauncherEvent event, LauncherAtom.ItemInfo itemInfo) {
|
||||
Log.d(TAG, String.format("%s\n%s", event.name(), itemInfo));
|
||||
// Call StatsLog method
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs snapshot, or impression of the current workspace.
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.model.data;
|
||||
|
||||
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_PREDICTION;
|
||||
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_DEEP_SHORTCUT;
|
||||
@@ -123,6 +124,12 @@ public class ItemInfo {
|
||||
*/
|
||||
public CharSequence contentDescription;
|
||||
|
||||
/**
|
||||
* When the instance is created using {@link #copyFrom}, this field is used to keep track of
|
||||
* original {@link ComponentName}.
|
||||
*/
|
||||
private ComponentName mComponentName;
|
||||
|
||||
public UserHandle user;
|
||||
|
||||
public ItemInfo() {
|
||||
@@ -145,6 +152,7 @@ public class ItemInfo {
|
||||
container = info.container;
|
||||
user = info.user;
|
||||
contentDescription = info.contentDescription;
|
||||
mComponentName = info.getTargetComponent();
|
||||
}
|
||||
|
||||
public Intent getIntent() {
|
||||
@@ -153,12 +161,7 @@ public class ItemInfo {
|
||||
|
||||
@Nullable
|
||||
public ComponentName getTargetComponent() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
return intent.getComponent();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return Optional.ofNullable(getIntent()).map(Intent::getComponent).orElse(mComponentName);
|
||||
}
|
||||
|
||||
public void writeToValues(ContentWriter writer) {
|
||||
@@ -247,8 +250,7 @@ public class ItemInfo {
|
||||
/**
|
||||
* Creates {@link LauncherAtom.ItemInfo} with important fields and parent container info.
|
||||
*/
|
||||
public LauncherAtom.ItemInfo buildProto(Intent intent, FolderInfo fInfo) {
|
||||
|
||||
public LauncherAtom.ItemInfo buildProto(FolderInfo fInfo) {
|
||||
LauncherAtom.ItemInfo.Builder itemBuilder = LauncherAtom.ItemInfo.newBuilder();
|
||||
itemBuilder.setIsWork(user != Process.myUserHandle());
|
||||
Optional<ComponentName> nullableComponent = Optional.ofNullable(getTargetComponent());
|
||||
@@ -270,7 +272,14 @@ public class ItemInfo {
|
||||
.orElse(LauncherAtom.Shortcut.newBuilder()));
|
||||
break;
|
||||
case ITEM_TYPE_APPWIDGET:
|
||||
setItemBuilder(itemBuilder);
|
||||
itemBuilder
|
||||
.setWidget(nullableComponent
|
||||
.map(component -> LauncherAtom.Widget.newBuilder()
|
||||
.setComponentName(component.flattenToShortString())
|
||||
.setPackageName(component.getPackageName()))
|
||||
.orElse(LauncherAtom.Widget.newBuilder())
|
||||
.setSpanX(spanX)
|
||||
.setSpanY(spanY));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -282,6 +291,7 @@ public class ItemInfo {
|
||||
|
||||
switch (fInfo.container) {
|
||||
case CONTAINER_HOTSEAT:
|
||||
case CONTAINER_HOTSEAT_PREDICTION:
|
||||
folderBuilder.setHotseat(LauncherAtom.HotseatContainer.newBuilder()
|
||||
.setIndex(fInfo.screenId));
|
||||
break;
|
||||
@@ -295,6 +305,7 @@ public class ItemInfo {
|
||||
} else {
|
||||
switch (container) {
|
||||
case CONTAINER_HOTSEAT:
|
||||
case CONTAINER_HOTSEAT_PREDICTION:
|
||||
itemBuilder.setContainerInfo(
|
||||
ContainerInfo.newBuilder().setHotseat(
|
||||
LauncherAtom.HotseatContainer.newBuilder().setIndex(screenId)));
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.Process;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.AppWidgetResizeFrame;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
@@ -142,6 +144,12 @@ public class LauncherAppWidgetInfo extends ItemInfo {
|
||||
return appWidgetId <= CUSTOM_WIDGET_ID;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ComponentName getTargetComponent() {
|
||||
return providerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddToDatabase(ContentWriter writer) {
|
||||
super.onAddToDatabase(writer);
|
||||
|
||||
Reference in New Issue
Block a user