From: Jon Miranda Date: Wed, 22 Mar 2017 17:25:17 +0000 (-0700) Subject: Add isInMultiWindowMode bool to all logs. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fe96432b43c456ee51da1abe3a2d5b87938ac567;p=android-x86%2Fpackages-apps-Launcher3.git Add isInMultiWindowMode bool to all logs. Example output: D/UserEvent: action:LONGPRESS Source child:WORKSPACE id=0 Elapsed container 1850 ms session 1850 ms action 0 ms isInMultiWindowMode true Bug: 34250955 Change-Id: If21484e8bbb0f4f311c2eb6e94b7dcea6d2431af --- diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto index c42b142f7..17dec37eb 100644 --- a/protos/launcher_log.proto +++ b/protos/launcher_log.proto @@ -149,4 +149,6 @@ message LauncherEvent { 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 e1a3ad0d6..410d590ad 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -38,11 +38,16 @@ public abstract class BaseActivity extends Activity { 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 2dba83df6..660037e0e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -366,7 +366,7 @@ public class Launcher extends BaseActivity // 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 90e453117..07e99c693 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -30,7 +30,6 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.ProviderConfig; -import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent; @@ -63,17 +62,11 @@ public class UserEventDispatcher { private static final boolean IS_VERBOSE = ProviderConfig.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; } /** @@ -118,6 +111,7 @@ public class UserEventDispatcher { private long mElapsedContainerMillis; private long mElapsedSessionMillis; private long mActionDurationMillis; + private boolean mIsInMultiWindowMode; // Used for filling in predictedRank on {@link Target}s. private List mPredictedApps; @@ -302,6 +296,7 @@ public class UserEventDispatcher { } public void dispatchUserEvent(LauncherEvent ev, Intent intent) { + ev.isInMultiWindowMode = mIsInMultiWindowMode; ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis; ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis; @@ -320,6 +315,7 @@ public class UserEventDispatcher { ev.elapsedContainerMillis, ev.elapsedSessionMillis, ev.actionDurationMillis); + log += "\n isInMultiWindowMode " + ev.isInMultiWindowMode; Log.d(TAG, log); }