use of com.android.launcher3.logging.DumpTargetWrapper in project Neo-Launcher by NeoApplications.
the class BgDataModel method dumpProto.
private synchronized void dumpProto(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
// Add top parent nodes. (L1)
DumpTargetWrapper hotseat = new DumpTargetWrapper(ContainerType.HOTSEAT, 0);
IntSparseArrayMap<DumpTargetWrapper> workspaces = new IntSparseArrayMap<>();
IntArray workspaceScreens = collectWorkspaceScreens();
for (int i = 0; i < workspaceScreens.size(); i++) {
workspaces.put(workspaceScreens.get(i), new DumpTargetWrapper(ContainerType.WORKSPACE, i));
}
DumpTargetWrapper dtw;
// Add non leaf / non top nodes (L2)
for (int i = 0; i < folders.size(); i++) {
FolderInfo fInfo = folders.valueAt(i);
dtw = new DumpTargetWrapper(ContainerType.FOLDER, folders.size());
dtw.writeToDumpTarget(fInfo);
for (WorkspaceItemInfo sInfo : fInfo.contents) {
DumpTargetWrapper child = new DumpTargetWrapper(sInfo);
child.writeToDumpTarget(sInfo);
dtw.add(child);
}
if (fInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
hotseat.add(dtw);
} else if (fInfo.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
workspaces.get(fInfo.screenId).add(dtw);
}
}
// Add leaf nodes (L3): *Info
for (int i = 0; i < workspaceItems.size(); i++) {
ItemInfo info = workspaceItems.get(i);
if (info instanceof FolderInfo) {
continue;
}
dtw = new DumpTargetWrapper(info);
dtw.writeToDumpTarget(info);
if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
hotseat.add(dtw);
} else if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
workspaces.get(info.screenId).add(dtw);
}
}
for (int i = 0; i < appWidgets.size(); i++) {
ItemInfo info = appWidgets.get(i);
dtw = new DumpTargetWrapper(info);
dtw.writeToDumpTarget(info);
if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
hotseat.add(dtw);
} else if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
workspaces.get(info.screenId).add(dtw);
}
}
// Traverse target wrapper
ArrayList<DumpTarget> targetList = new ArrayList<>();
targetList.addAll(hotseat.getFlattenedList());
for (int i = 0; i < workspaces.size(); i++) {
targetList.addAll(workspaces.valueAt(i).getFlattenedList());
}
if (Arrays.asList(args).contains("--debug")) {
for (int i = 0; i < targetList.size(); i++) {
writer.println(prefix + DumpTargetWrapper.getDumpTargetStr(targetList.get(i)));
}
return;
} else {
LauncherDumpProto.LauncherImpression proto = new LauncherDumpProto.LauncherImpression();
proto.targets = new DumpTarget[targetList.size()];
for (int i = 0; i < targetList.size(); i++) {
proto.targets[i] = targetList.get(i);
}
FileOutputStream fos = new FileOutputStream(fd);
try {
fos.write(MessageNano.toByteArray(proto));
Log.d(TAG, MessageNano.toByteArray(proto).length + "Bytes");
} catch (IOException e) {
Log.e(TAG, "Exception writing dumpsys --proto", e);
}
}
}
Aggregations