Merge "Minor Refactoring only: no functional change" into ub-launcher3-master
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
index c42b142..17dec37 100644
--- a/protos/launcher_log.proto
+++ b/protos/launcher_log.proto
@@ -149,4 +149,6 @@
   optional int64 action_duration_millis = 4;
   optional int64 elapsed_container_millis = 5;
   optional int64 elapsed_session_millis = 6;
+
+  optional bool is_in_multi_window_mode = 7;
 }
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index e1a3ad0..410d590 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -38,11 +38,16 @@
 
     public final UserEventDispatcher getUserEventDispatcher() {
         if (mUserEventDispatcher == null) {
-            mUserEventDispatcher = UserEventDispatcher.get(this);
+            mUserEventDispatcher = UserEventDispatcher.newInstance(this,
+                    isInMultiWindowModeCompat());
         }
         return mUserEventDispatcher;
     }
 
+    public boolean isInMultiWindowModeCompat() {
+        return Utilities.ATLEAST_NOUGAT && isInMultiWindowMode();
+    }
+
     public static BaseActivity fromContext(Context context) {
         if (context instanceof BaseActivity) {
             return (BaseActivity) context;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 28d0b58..0d56c5a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -365,7 +365,7 @@
 
         // Load configuration-specific DeviceProfile
         mDeviceProfile = app.getInvariantDeviceProfile().getDeviceProfile(this);
-        if (Utilities.ATLEAST_NOUGAT && isInMultiWindowMode()) {
+        if (isInMultiWindowModeCompat()) {
             Display display = getWindowManager().getDefaultDisplay();
             Point mwSize = new Point();
             display.getSize(mwSize);
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 04ca247..7899846 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -62,17 +62,11 @@
     private static final boolean IS_VERBOSE =
             FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT);
 
-    private static UserEventDispatcher sInstance;
-    private static final Object LOCK = new Object();
-
-    public static UserEventDispatcher get(Context context) {
-        synchronized (LOCK) {
-            if (sInstance == null) {
-                sInstance = Utilities.getOverrideObject(UserEventDispatcher.class,
-                        context.getApplicationContext(), R.string.user_event_dispatcher_class);
-            }
-            return sInstance;
-        }
+    public static UserEventDispatcher newInstance(Context context, boolean isInMultiWindowMode) {
+        UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class,
+                context.getApplicationContext(), R.string.user_event_dispatcher_class);
+        ued.mIsInMultiWindowMode = isInMultiWindowMode;
+        return ued;
     }
 
     /**
@@ -117,6 +111,7 @@
     private long mElapsedContainerMillis;
     private long mElapsedSessionMillis;
     private long mActionDurationMillis;
+    private boolean mIsInMultiWindowMode;
 
     // Used for filling in predictedRank on {@link Target}s.
     private List<ComponentKey> mPredictedApps;
@@ -301,6 +296,7 @@
     }
 
     public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
+        ev.isInMultiWindowMode = mIsInMultiWindowMode;
         ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
         ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
 
@@ -319,6 +315,7 @@
                 ev.elapsedContainerMillis,
                 ev.elapsedSessionMillis,
                 ev.actionDurationMillis);
+        log += "\n isInMultiWindowMode " + ev.isInMultiWindowMode;
         Log.d(TAG, log);
     }