Search in sources :

Example 1 with DumpTargetWrapper

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);
        }
    }
}
Also used : DumpTarget(com.android.launcher3.model.nano.LauncherDumpProto.DumpTarget) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) IntSparseArrayMap(com.android.launcher3.util.IntSparseArrayMap) DumpTargetWrapper(com.android.launcher3.logging.DumpTargetWrapper) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FolderInfo(com.android.launcher3.FolderInfo) LauncherDumpProto(com.android.launcher3.model.nano.LauncherDumpProto) IntArray(com.android.launcher3.util.IntArray) FileOutputStream(java.io.FileOutputStream) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Aggregations

FolderInfo (com.android.launcher3.FolderInfo)1 ItemInfo (com.android.launcher3.ItemInfo)1 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)1 DumpTargetWrapper (com.android.launcher3.logging.DumpTargetWrapper)1 LauncherDumpProto (com.android.launcher3.model.nano.LauncherDumpProto)1 DumpTarget (com.android.launcher3.model.nano.LauncherDumpProto.DumpTarget)1 IntArray (com.android.launcher3.util.IntArray)1 IntSparseArrayMap (com.android.launcher3.util.IntSparseArrayMap)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1