Fix NPE / add downX,Y location for all swipes/ add extra debugging info

Bug: 122700646
Bug: 127840207

Change-Id: I5862c8950565df172a933114e1fb2f9c4575593e
This commit is contained in:
Hyunyoung Song
2019-04-24 11:32:20 -07:00
parent 01b8b68db7
commit bf44bc342f
8 changed files with 39 additions and 18 deletions
@@ -41,7 +41,6 @@ import java.lang.reflect.Modifier;
/**
* Helper methods for logging.
*/
@Deprecated
public class LoggerUtils {
private static final ArrayMap<Class, SparseArray<String>> sNameCache = new ArrayMap<>();
private static final String UNKNOWN = "UNKNOWN";
@@ -77,10 +76,17 @@ public class LoggerUtils {
if (action.touch == Action.Touch.SWIPE || action.touch == Action.Touch.FLING) {
str += " direction=" + getFieldName(action.dir, Action.Direction.class);
}
return str;
case Action.Type.COMMAND: return getFieldName(action.command, Action.Command.class);
break;
case Action.Type.COMMAND:
str += getFieldName(action.command, Action.Command.class);
break;
default: return getFieldName(action.type, Action.Type.class);
}
if (action.touch == Action.Touch.SWIPE || action.touch == Action.Touch.FLING ||
(action.command == Action.Command.BACK && action.dir != Action.Direction.NONE)) {
str += " direction=" + getFieldName(action.dir, Action.Direction.class);
}
return str;
}
public static String getTargetStr(Target t) {
@@ -102,13 +108,17 @@ public class LoggerUtils {
t.containerType == NAVBAR) {
str += " id=" + t.pageIndex;
} else if (t.containerType == ContainerType.FOLDER) {
str += " grid(" + t.gridX + "," + t.gridY+ ")";
str += " grid(" + t.gridX + "," + t.gridY + ")";
}
break;
default:
str += "UNKNOWN TARGET TYPE";
}
if (t.spanX != 1 || t.spanY != 1) {
str += " span(" + t.spanX + "," + t.spanY + ")";
}
if (t.tipType != TipType.DEFAULT_NONE) {
str += " " + getFieldName(t.tipType, TipType.class);
}
@@ -96,7 +96,6 @@ public class UserEventDispatcher implements ResourceBasedOverride {
* Fills in the container data on the given event if the given view is not null.
* @return whether container data was added.
*/
@Deprecated
public static boolean fillInLogContainerData(LauncherLogProto.LauncherEvent event, @Nullable View v) {
// Fill in grid(x,y), pageIndex of the child and container type of the parent
LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(v);
@@ -293,7 +292,7 @@ public class UserEventDispatcher implements ResourceBasedOverride {
* (1) WORKSPACE: if the launcher is the foreground activity
* (2) APP: if another app was the foreground activity
*/
public void logStateChangeAction(int action, int dir, int srcChildTargetType,
public void logStateChangeAction(int action, int dir, int downX, int downY, int srcChildTargetType,
int srcParentContainerType, int dstContainerType,
int pageIndex) {
LauncherEvent event;
@@ -311,6 +310,8 @@ public class UserEventDispatcher implements ResourceBasedOverride {
event.action.dir = dir;
event.action.isStateChange = true;
event.srcTarget[0].pageIndex = pageIndex;
event.srcTarget[0].spanX = downX;
event.srcTarget[0].spanY = downY;
dispatchUserEvent(event, null);
resetElapsedContainerMillis("state changed");
}
@@ -325,7 +326,7 @@ public class UserEventDispatcher implements ResourceBasedOverride {
public void logDeepShortcutsOpen(View icon) {
LogContainerProvider provider = StatsLogUtils.getLaunchProviderRecursive(icon);
if (icon == null || !(icon.getTag() instanceof ItemInfo)) {
if (icon == null || !(icon.getTag() instanceof ItemInfo || provider == null)) {
return;
}
ItemInfo info = (ItemInfo) icon.getTag();
@@ -540,7 +540,7 @@ public abstract class AbstractStateChangeTouchController
private void logReachedState(int logAction, LauncherState targetState) {
// Transition complete. log the action
mLauncher.getUserEventDispatcher().logStateChangeAction(logAction,
getDirectionForLog(),
getDirectionForLog(), mDetector.getDownX(), mDetector.getDownY(),
mStartContainerType,
mStartState.containerType,
targetState.containerType,
@@ -180,6 +180,13 @@ public class SwipeDetector {
return mState == ScrollState.DRAGGING || mState == ScrollState.SETTLING;
}
public int getDownX() {
return (int) mDownPos.x;
}
public int getDownY() {
return (int) mDownPos.y;
}
/**
* There's no touch and there's no animation.
*/