Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit feba90fe authored by Jon Miranda's avatar Jon Miranda
Browse files

Added logging for HOME_INTENT and BACK commands.

Document: go/false-longpress-overview

Change-Id: If6ba4996c861a44f4950b41acb4246e3a483d8f2
parent 0860e41d
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ enum ItemType {
  FOLDER_ICON = 4;
  DEEPSHORTCUT = 5;
  SEARCHBOX = 6;
  EDITTEXT = 7;
}

// Used to define what type of container a Target would represent.
@@ -91,7 +92,9 @@ enum ControlType {
  APPINFO_TARGET = 7;
  RESIZE_HANDLE = 8;
  VERTICAL_SCROLL = 9;
  // HOME, BACK, GO_TO_PLAYSTORE
  HOME_INTENT = 10; // Deprecated, use enum Command instead
  BACK_BUTTON = 11; // Deprecated, use enum Command instead
  // GO_TO_PLAYSTORE
}

// Used to define the action component of the LauncherEvent.
@@ -99,6 +102,7 @@ message Action {
  enum Type {
    TOUCH = 0;
    AUTOMATED = 1;
    COMMAND = 2;
    // SOFT_KEYBOARD, HARD_KEYBOARD, ASSIST
  }
  enum Touch {
@@ -116,9 +120,16 @@ message Action {
    LEFT = 3;
    RIGHT = 4;
  }
  enum Command {
    HOME_INTENT = 0;
    BACK = 1;
  }
  optional Type type = 1;
  optional Touch touch = 2;
  optional Direction dir = 3;
  optional Command command = 4;
  // Log if the action was performed on outside of the container
  optional bool is_outside = 5;
}

//
+33 −1
Original line number Diff line number Diff line
@@ -1681,9 +1681,27 @@ public class Launcher extends Activity
                // Can be cases where mWorkspace is null, this prevents a NPE
                return;
            }
            // In all these cases, only animate if we're already on home

            // Note: There should be at most one log per method call. This is enforced implicitly
            // by using if-else statements.
            UserEventDispatcher ued = getUserEventDispatcher();

            // TODO: Log this case.
            mWorkspace.exitWidgetResizeMode();

            AbstractFloatingView topOpenView = AbstractFloatingView.getTopOpenView(this);
            if (topOpenView instanceof DeepShortcutsContainer) {
                ued.logActionCommand(LauncherLogProto.Action.HOME_INTENT,
                        topOpenView.getExtendedTouchView(), LauncherLogProto.DEEPSHORTCUTS);
            } else if (topOpenView instanceof Folder) {
                ued.logActionCommand(LauncherLogProto.Action.HOME_INTENT,
                            ((Folder) topOpenView).getFolderIcon(), LauncherLogProto.FOLDER);
            } else if (alreadyOnHome) {
                ued.logActionCommand(LauncherLogProto.Action.HOME_INTENT,
                        mWorkspace.getState().containerType, mWorkspace.getCurrentPage());
            }

            // In all these cases, only animate if we're already on home
            AbstractFloatingView.closeAllOpenViews(this, alreadyOnHome);
            exitSpringLoadedDragMode();

@@ -2187,20 +2205,34 @@ public class Launcher extends Activity
            return;
        }

        // Note: There should be at most one log per method call. This is enforced implicitly
        // by using if-else statements.
        UserEventDispatcher ued = getUserEventDispatcher();
        AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
        if (topView != null) {
            if (topView.getActiveTextView() != null) {
                topView.getActiveTextView().dispatchBackKey();
            } else {
                if (topView instanceof DeepShortcutsContainer) {
                    ued.logActionCommand(LauncherLogProto.Action.BACK,
                            topView.getExtendedTouchView(), LauncherLogProto.DEEPSHORTCUTS);
                } else if (topView instanceof Folder) {
                    ued.logActionCommand(LauncherLogProto.Action.BACK,
                            ((Folder) topView).getFolderIcon(), LauncherLogProto.FOLDER);
                }
                topView.close(true);
            }
        } else if (isAppsViewVisible()) {
            ued.logActionCommand(LauncherLogProto.Action.BACK, LauncherLogProto.ALLAPPS);
            showWorkspace(true);
        } else if (isWidgetsViewVisible())  {
            ued.logActionCommand(LauncherLogProto.Action.BACK, LauncherLogProto.WIDGETS);
            showOverviewMode(true);
        } else if (mWorkspace.isInOverviewMode()) {
            ued.logActionCommand(LauncherLogProto.Action.BACK, LauncherLogProto.OVERVIEW);
            showWorkspace(true);
        } else {
            // TODO: Log this case.
            mWorkspace.exitWidgetResizeMode();

            // Back button is a no-op here, but give at least some feedback for the button press
+8 −6
Original line number Diff line number Diff line
@@ -183,18 +183,20 @@ public class Workspace extends PagedView
    // in all apps or customize mode)

    public enum State {
        NORMAL          (false, false),
        NORMAL_HIDDEN   (false, false),
        SPRING_LOADED   (false, true),
        OVERVIEW        (true, true),
        OVERVIEW_HIDDEN (true, false);
        NORMAL          (false, false, LauncherLogProto.WORKSPACE),
        NORMAL_HIDDEN   (false, false, LauncherLogProto.ALLAPPS),
        SPRING_LOADED   (false, true, LauncherLogProto.WORKSPACE),
        OVERVIEW        (true, true, LauncherLogProto.OVERVIEW),
        OVERVIEW_HIDDEN (true, false, LauncherLogProto.WIDGETS);

        public final boolean shouldUpdateWidget;
        public final boolean hasMultipleVisiblePages;
        public final int containerType;

        State(boolean shouldUpdateWidget, boolean hasMultipleVisiblePages) {
        State(boolean shouldUpdateWidget, boolean hasMultipleVisiblePages, int containerType) {
            this.shouldUpdateWidget = shouldUpdateWidget;
            this.hasMultipleVisiblePages = hasMultipleVisiblePages;
            this.containerType = containerType;
        }
    }

+4 −1
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.pageindicators.PageIndicatorDots;
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.CircleRevealOutlineProvider;
@@ -388,6 +387,10 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
        return isEditingName() ? mFolderName : null;
    }

    public FolderIcon getFolderIcon() {
        return mFolderIcon;
    }

    /**
     * We need to handle touch events to prevent them from falling through to the workspace below.
     */
+42 −7
Original line number Diff line number Diff line
@@ -20,7 +20,15 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
public class LoggerUtils {
    private static final String TAG = "LoggerUtils";

    public static String getActionStr(LauncherLogProto.Action action) {
    private static String getCommandStr(Action action) {
        switch (action.command) {
            case Action.HOME_INTENT: return "HOME_INTENT";
            case Action.BACK: return "BACK";
            default: return "UNKNOWN";
        }
    }

    private static String getTouchStr(Action action) {
        switch (action.touch) {
            case Action.TAP: return "TAP";
            case Action.LONGPRESS: return "LONGPRESS";
@@ -32,6 +40,14 @@ public class LoggerUtils {
        }
    }

    public static String getActionStr(LauncherLogProto.Action action) {
        switch (action.type) {
            case Action.TOUCH: return getTouchStr(action);
            case Action.COMMAND: return getCommandStr(action);
            default: return "UNKNOWN";
        }
    }

    public static String getTargetStr(Target t) {
        String typeStr = "";
        if (t == null){
@@ -61,6 +77,7 @@ public class LoggerUtils {
            case LauncherLogProto.DEEPSHORTCUT: typeStr = "DEEPSHORTCUT"; break;
            case LauncherLogProto.FOLDER_ICON: typeStr = "FOLDERICON"; break;
            case LauncherLogProto.SEARCHBOX: typeStr = "SEARCHBOX"; break;
            case LauncherLogProto.EDITTEXT: typeStr = "EDITTEXT"; break;

            default: typeStr = "UNKNOWN";
        }
@@ -172,24 +189,42 @@ public class LoggerUtils {
        return event;
    }

    /**
     * Used for commands.
     */
    public static LauncherLogProto.LauncherEvent initLauncherEvent(int command,
            boolean createSrcTarget) {
        LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();
        event.action = new LauncherLogProto.Action();
        event.action.type = Action.COMMAND;
        event.action.command = command;
        event.srcTarget = null;

        if (createSrcTarget) {
            event.srcTarget = new LauncherLogProto.Target[1];
            event.srcTarget[0] = new LauncherLogProto.Target();
            event.srcTarget[0].type = Target.CONTAINER;
        }
        return event;
    }

    /**
     * Used for drag and drop interaction.
     */
    public static LauncherLogProto.LauncherEvent initLauncherEvent(
            int actionType,
            View v,
            ItemInfo info,
            int parentSrcTargetType,
            View parentDestTargetType){
        LauncherLogProto.LauncherEvent event = new LauncherLogProto.LauncherEvent();

        event.srcTarget = new LauncherLogProto.Target[2];
        event.srcTarget[0] = initTarget(v, info);
        event.srcTarget[0] = initTarget(info);
        event.srcTarget[1] = new LauncherLogProto.Target();
        event.srcTarget[1].type = parentSrcTargetType;

        event.destTarget = new LauncherLogProto.Target[2];
        event.destTarget[0] = initTarget(v, info);
        event.destTarget[0] = initTarget(info);
        event.destTarget[1] = initDropTarget(parentDestTargetType);

        event.action = new LauncherLogProto.Action();
@@ -197,7 +232,7 @@ public class LoggerUtils {
        return event;
    }

    private static Target initTarget(View v, ItemInfo info) {
    private static Target initTarget(ItemInfo info) {
        Target t = new LauncherLogProto.Target();
        t.type = Target.ITEM;
        switch (info.itemType) {
@@ -243,6 +278,6 @@ public class LoggerUtils {
        if (!(v.getTag() instanceof ItemInfo)) {
            return t;
        }
        return initTarget(v, (ItemInfo) v.getTag());
        return initTarget((ItemInfo) v.getTag());
    }
}
Loading