Merge "Add support for logging multiple attributes per item." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6dd3fc9465
@@ -23,6 +23,8 @@ import "launcher_atom_extension.proto";
|
||||
//
|
||||
// ItemInfos
|
||||
message ItemInfo {
|
||||
reserved 8;
|
||||
|
||||
oneof Item {
|
||||
Application application = 1;
|
||||
Task task = 2;
|
||||
@@ -42,7 +44,14 @@ message ItemInfo {
|
||||
optional ContainerInfo container_info = 7;
|
||||
|
||||
// Stores the origin of the Item
|
||||
optional Attribute attribute = 8;
|
||||
repeated Attribute item_attributes = 12;
|
||||
}
|
||||
|
||||
message LauncherAttributes{
|
||||
|
||||
// Integer value of item attribute enum
|
||||
// (e.g. SUGGESTED_LABEL, ALL_APPS_SEARCH_RESULT_SETTING etc)
|
||||
repeated int32 item_attributes = 1;
|
||||
}
|
||||
|
||||
// Represents various launcher surface where items are placed.
|
||||
|
||||
@@ -42,10 +42,12 @@ import androidx.slice.SliceItem;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logger.LauncherAtom.Attribute;
|
||||
import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
||||
import com.android.launcher3.logger.LauncherAtom.FolderContainer.ParentContainerCase;
|
||||
import com.android.launcher3.logger.LauncherAtom.FolderIcon;
|
||||
import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||
import com.android.launcher3.logger.LauncherAtom.LauncherAttributes;
|
||||
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||
import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer;
|
||||
import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes;
|
||||
@@ -88,7 +90,6 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
private static final int FOLDER_HIERARCHY_OFFSET = 100;
|
||||
private static final int SEARCH_RESULT_HIERARCHY_OFFSET = 200;
|
||||
private static final int EXTENDED_CONTAINERS_HIERARCHY_OFFSET = 300;
|
||||
private static final int ATTRIBUTE_MULTIPLIER = 100;
|
||||
|
||||
/**
|
||||
* Flags for converting SearchAttribute to integer value.
|
||||
@@ -130,8 +131,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_SNAPSHOT,
|
||||
LAUNCHER_WORKSPACE_SNAPSHOT.getId() /* event_id */,
|
||||
info.getAttribute().getNumber() * ATTRIBUTE_MULTIPLIER
|
||||
+ info.getItemCase().getNumber() /* target_id */,
|
||||
info.getItemCase().getNumber() /* target_id */,
|
||||
instanceId.getId() /* instance_id */,
|
||||
0 /* uid */,
|
||||
getPackageName(info) /* package_name */,
|
||||
@@ -144,15 +144,22 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
getParentPageId(info) /* page_id_parent */,
|
||||
getHierarchy(info) /* hierarchy */,
|
||||
info.getIsWork() /* is_work_profile */,
|
||||
info.getAttribute().getNumber() /* origin */,
|
||||
0 /* origin */,
|
||||
getCardinality(info) /* cardinality */,
|
||||
info.getWidget().getSpanX(),
|
||||
info.getWidget().getSpanY(),
|
||||
getFeatures(info),
|
||||
null /* attributes */
|
||||
getAttributes(info) /* attributes */
|
||||
);
|
||||
}
|
||||
|
||||
private static byte[] getAttributes(LauncherAtom.ItemInfo itemInfo) {
|
||||
LauncherAttributes.Builder responseBuilder = LauncherAttributes.newBuilder();
|
||||
itemInfo.getItemAttributesList().stream().map(Attribute::getNumber).forEach(
|
||||
responseBuilder::addItemAttributes);
|
||||
return responseBuilder.build().toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds {@link StatsEvent} from {@link LauncherAtom.ItemInfo}. Used for pulled atom callback
|
||||
* implementation.
|
||||
@@ -162,8 +169,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
return SysUiStatsLog.buildStatsEvent(
|
||||
SysUiStatsLog.LAUNCHER_LAYOUT_SNAPSHOT, // atom ID,
|
||||
LAUNCHER_WORKSPACE_SNAPSHOT.getId(), // event_id = 1;
|
||||
info.getAttribute().getNumber() * ATTRIBUTE_MULTIPLIER
|
||||
+ info.getItemCase().getNumber(), // item_id = 2;
|
||||
info.getItemCase().getNumber(), // item_id = 2;
|
||||
instanceId == null ? 0 : instanceId.getId(), //instance_id = 3;
|
||||
0, //uid = 4 [(is_uid) = true];
|
||||
getPackageName(info), // package_name = 5;
|
||||
@@ -176,11 +182,11 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
getParentPageId(info), //page_id_parent = 12 [default = -2];
|
||||
getHierarchy(info), // container_id = 13;
|
||||
info.getIsWork(), // is_work_profile = 14;
|
||||
info.getAttribute().getNumber(), // attribute_id = 15;
|
||||
0, // attribute_id = 15;
|
||||
getCardinality(info), // cardinality = 16;
|
||||
info.getWidget().getSpanX(), // span_x = 17 [default = 1];
|
||||
info.getWidget().getSpanY(), // span_y = 18 [default = 1];
|
||||
null /* attributes */
|
||||
getAttributes(info) /* attributes */
|
||||
);
|
||||
}
|
||||
|
||||
@@ -403,8 +409,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
null /* launcher extensions, deprecated */,
|
||||
false /* quickstep_enabled, deprecated */,
|
||||
event.getId() /* event_id */,
|
||||
atomInfo.getAttribute().getNumber() * ATTRIBUTE_MULTIPLIER
|
||||
+ atomInfo.getItemCase().getNumber() /* target_id */,
|
||||
atomInfo.getItemCase().getNumber() /* target_id */,
|
||||
instanceId.getId() /* instance_id TODO */,
|
||||
0 /* uid TODO */,
|
||||
getPackageName(atomInfo) /* package_name */,
|
||||
@@ -424,7 +429,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
getCardinality(atomInfo) /* cardinality */,
|
||||
getFeatures(atomInfo) /* features */,
|
||||
getSearchAttributes(atomInfo) /* searchAttributes */,
|
||||
null /* attributes */
|
||||
getAttributes(atomInfo) /* attributes */
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class FolderInfo extends ItemInfo {
|
||||
return getDefaultItemInfoBuilder()
|
||||
.setFolderIcon(folderIcon)
|
||||
.setRank(rank)
|
||||
.setAttribute(getLabelState().mLogAttribute)
|
||||
.addItemAttributes(getLabelState().mLogAttribute)
|
||||
.setContainerInfo(getContainerInfo())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ public class LauncherAppWidgetInfo extends ItemInfo {
|
||||
LauncherAtom.ItemInfo info = super.buildProto(folderInfo);
|
||||
return info.toBuilder()
|
||||
.setWidget(info.getWidget().toBuilder().setWidgetFeatures(widgetFeatures))
|
||||
.setAttribute(getAttribute(sourceContainer))
|
||||
.addItemAttributes(getAttribute(sourceContainer))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PendingAddWidgetInfo extends PendingAddItemInfo {
|
||||
public LauncherAtom.ItemInfo buildProto(FolderInfo folderInfo) {
|
||||
LauncherAtom.ItemInfo info = super.buildProto(folderInfo);
|
||||
return info.toBuilder()
|
||||
.setAttribute(LauncherAppWidgetInfo.getAttribute(sourceContainer))
|
||||
.addItemAttributes(LauncherAppWidgetInfo.getAttribute(sourceContainer))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user