mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Add FolderInfo label source / Add instance id to snapshot logging
Bug: 155719741 Change-Id: I6611d67bc7a940b6e7cf80ec788406c9f2499318
This commit is contained in:
@@ -38,7 +38,7 @@ message ItemInfo {
|
||||
optional ContainerInfo container_info = 7;
|
||||
|
||||
// Stores the origin of the Item
|
||||
optional Origin source = 8;
|
||||
optional Attribute attribute = 8;
|
||||
}
|
||||
|
||||
// Represents various launcher surface where items are placed.
|
||||
@@ -81,7 +81,7 @@ message ShortcutsContainer {
|
||||
message SettingsContainer {
|
||||
}
|
||||
|
||||
enum Origin {
|
||||
enum Attribute {
|
||||
UNKNOWN = 0;
|
||||
DEFAULT_LAYOUT = 1; // icon automatically placed in workspace, folder, hotseat
|
||||
BACKUP_RESTORE = 2; // icon layout restored from backup
|
||||
@@ -91,6 +91,8 @@ enum Origin {
|
||||
ADD_TO_HOMESCREEN = 6; // play install + launcher home setting
|
||||
ALLAPPS_PREDICTION = 7; // from prediction bar in all apps container
|
||||
HOTSEAT_PREDICTION = 8; // from prediction bar in hotseat container
|
||||
SUGGESTED_LABEL = 9; // folder icon's label was suggested
|
||||
MANUAL_LABEL = 10; // folder icon's label was manually edited
|
||||
}
|
||||
|
||||
// Main app icons
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.model.AllAppsList;
|
||||
import com.android.launcher3.model.BaseModelUpdateTask;
|
||||
@@ -180,33 +181,37 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
private class SnapshotWorker extends BaseModelUpdateTask {
|
||||
private final InstanceId mInstanceId;
|
||||
SnapshotWorker() {
|
||||
mInstanceId = new InstanceIdSequence(
|
||||
1 << 20 /*InstanceId.INSTANCE_ID_MAX*/).newInstanceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
|
||||
IntSparseArrayMap<FolderInfo> folders = dataModel.folders.clone();
|
||||
ArrayList<ItemInfo> workspaceItems = (ArrayList) dataModel.workspaceItems.clone();
|
||||
ArrayList<LauncherAppWidgetInfo> appWidgets = (ArrayList) dataModel.appWidgets.clone();
|
||||
|
||||
for (ItemInfo info : workspaceItems) {
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null);
|
||||
writeSnapshot(atomInfo);
|
||||
writeSnapshot(atomInfo, mInstanceId);
|
||||
}
|
||||
for (FolderInfo fInfo : folders) {
|
||||
for (ItemInfo info : fInfo.contents) {
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(fInfo);
|
||||
writeSnapshot(atomInfo);
|
||||
writeSnapshot(atomInfo, mInstanceId);
|
||||
}
|
||||
}
|
||||
for (ItemInfo info : appWidgets) {
|
||||
LauncherAtom.ItemInfo atomInfo = info.buildProto(null);
|
||||
writeSnapshot(atomInfo);
|
||||
writeSnapshot(atomInfo, mInstanceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeSnapshot(LauncherAtom.ItemInfo info) {
|
||||
private static void writeSnapshot(LauncherAtom.ItemInfo info, InstanceId instanceId) {
|
||||
if (IS_VERBOSE) {
|
||||
Log.d(TAG, "\nwriteSnapshot:" + info);
|
||||
Log.d(TAG, String.format("\nwriteSnapshot(%d):\n%s", instanceId.getId(), info));
|
||||
}
|
||||
if (!Utilities.ATLEAST_R) {
|
||||
return;
|
||||
@@ -214,7 +219,7 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_SNAPSHOT,
|
||||
0 /* event_id */,
|
||||
info.getItemCase().getNumber() /* target_id */,
|
||||
0 /* instance_id */,
|
||||
instanceId.getId() /* instance_id */,
|
||||
0 /* uid */,
|
||||
getPackageName(info) /* package_name */,
|
||||
getComponentName(info) /* component_name */,
|
||||
@@ -226,8 +231,8 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
getPageId(info, true) /* page_id_parent */,
|
||||
getHierarchy(info) /* hierarchy */,
|
||||
info.getIsWork() /* is_work_profile */,
|
||||
0 /* origin TODO */,
|
||||
0 /* cardinality */,
|
||||
info.getAttribute().getNumber() /* origin */,
|
||||
info.getFolderIcon().getCardinality() /* cardinality */,
|
||||
info.getWidget().getSpanX(),
|
||||
info.getWidget().getSpanY());
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import static androidx.core.util.Preconditions.checkNotNull;
|
||||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
|
||||
import static com.android.launcher3.logger.LauncherAtom.Attribute.MANUAL_LABEL;
|
||||
import static com.android.launcher3.logger.LauncherAtom.Attribute.SUGGESTED_LABEL;
|
||||
import static com.android.launcher3.userevent.LauncherLogProto.Target.FromFolderLabelState.FROM_CUSTOM;
|
||||
import static com.android.launcher3.userevent.LauncherLogProto.Target.FromFolderLabelState.FROM_EMPTY;
|
||||
import static com.android.launcher3.userevent.LauncherLogProto.Target.FromFolderLabelState.FROM_FOLDER_LABEL_STATE_UNSPECIFIED;
|
||||
@@ -205,6 +207,7 @@ public class FolderInfo extends ItemInfo {
|
||||
return getDefaultItemInfoBuilder()
|
||||
.setFolderIcon(LauncherAtom.FolderIcon.newBuilder().setCardinality(contents.size()))
|
||||
.setRank(rank)
|
||||
.setAttribute(fromCustom ? MANUAL_LABEL : SUGGESTED_LABEL)
|
||||
.setContainerInfo(getContainerInfo())
|
||||
.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user