Log whether an event happened during landscape mode or not

b/38211234

<sample log>
  action:TAP
  Source child:APP_ICON, packageHash=-1046965711, componentHash=-371608779, intentHash=208792422, grid(4,4), span(1,1), pageIdx=0	parent:WORKSPACE id=0
  Elapsed container 3071 ms session 3071 ms action 0 ms
  isInLandscapeMode true
  isInMultiWindowMode false
</sample log>

Change-Id: I44dfe4e7ee2a41c56a50cc2b507bbbeedc458018
This commit is contained in:
Hyunyoung Song 2017-05-16 11:04:26 -07:00
parent 0270039b98
commit d5a9b57713
3 changed files with 8 additions and 2 deletions

View File

@ -156,4 +156,5 @@ message LauncherEvent {
optional int64 elapsed_session_millis = 6; optional int64 elapsed_session_millis = 6;
optional bool is_in_multi_window_mode = 7; optional bool is_in_multi_window_mode = 7;
optional bool is_in_landscape_mode = 8;
} }

View File

@ -39,7 +39,7 @@ public abstract class BaseActivity extends Activity {
public final UserEventDispatcher getUserEventDispatcher() { public final UserEventDispatcher getUserEventDispatcher() {
if (mUserEventDispatcher == null) { if (mUserEventDispatcher == null) {
mUserEventDispatcher = UserEventDispatcher.newInstance(this, mUserEventDispatcher = UserEventDispatcher.newInstance(this,
isInMultiWindowModeCompat()); mDeviceProfile.isLandscape, isInMultiWindowModeCompat());
} }
return mUserEventDispatcher; return mUserEventDispatcher;
} }

View File

@ -62,9 +62,11 @@ public class UserEventDispatcher {
private static final boolean IS_VERBOSE = private static final boolean IS_VERBOSE =
ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT); ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT);
public static UserEventDispatcher newInstance(Context context, boolean isInMultiWindowMode) { public static UserEventDispatcher newInstance(Context context, boolean isInLandscapeMode,
boolean isInMultiWindowMode) {
UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class, UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class,
context.getApplicationContext(), R.string.user_event_dispatcher_class); context.getApplicationContext(), R.string.user_event_dispatcher_class);
ued.mIsInLandscapeMode = isInLandscapeMode;
ued.mIsInMultiWindowMode = isInMultiWindowMode; ued.mIsInMultiWindowMode = isInMultiWindowMode;
return ued; return ued;
} }
@ -112,6 +114,7 @@ public class UserEventDispatcher {
private long mElapsedSessionMillis; private long mElapsedSessionMillis;
private long mActionDurationMillis; private long mActionDurationMillis;
private boolean mIsInMultiWindowMode; private boolean mIsInMultiWindowMode;
private boolean mIsInLandscapeMode;
// Used for filling in predictedRank on {@link Target}s. // Used for filling in predictedRank on {@link Target}s.
private List<ComponentKey> mPredictedApps; private List<ComponentKey> mPredictedApps;
@ -296,6 +299,7 @@ public class UserEventDispatcher {
} }
public void dispatchUserEvent(LauncherEvent ev, Intent intent) { public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
ev.isInLandscapeMode = mIsInLandscapeMode;
ev.isInMultiWindowMode = mIsInMultiWindowMode; ev.isInMultiWindowMode = mIsInMultiWindowMode;
ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis; ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis; ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
@ -315,6 +319,7 @@ public class UserEventDispatcher {
ev.elapsedContainerMillis, ev.elapsedContainerMillis,
ev.elapsedSessionMillis, ev.elapsedSessionMillis,
ev.actionDurationMillis); ev.actionDurationMillis);
log += "\n isInLandscapeMode " + ev.isInLandscapeMode;
log += "\n isInMultiWindowMode " + ev.isInMultiWindowMode; log += "\n isInMultiWindowMode " + ev.isInMultiWindowMode;
Log.d(TAG, log); Log.d(TAG, log);
} }