summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2018-05-16 15:54:31 -0700
committerHyunyoung Song <hyunyoungs@google.com>2018-05-21 12:27:46 -0700
commitbd6fba9f589d02550c7542afa1906e2e3dd82a1b (patch)
tree551f130c3c83e2fb390d097b9d8a1454068f52c1
parent7b19b16f09237508076d89d6fda2e3d335344b98 (diff)
downloadandroid_packages_apps_Trebuchet-bd6fba9f589d02550c7542afa1906e2e3dd82a1b.tar.gz
android_packages_apps_Trebuchet-bd6fba9f589d02550c7542afa1906e2e3dd82a1b.tar.bz2
android_packages_apps_Trebuchet-bd6fba9f589d02550c7542afa1906e2e3dd82a1b.zip
onResume event should be logged (not twice but once)
Bug: 79541772 Change-Id: I5fe1271007e4579e1ec95d51c215ef48d0c6eedd
-rw-r--r--protos/launcher_log.proto1
-rw-r--r--src/com/android/launcher3/AbstractFloatingView.java6
-rw-r--r--src/com/android/launcher3/Launcher.java22
-rw-r--r--src/com/android/launcher3/logging/UserEventDispatcher.java12
4 files changed, 32 insertions, 9 deletions
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
index 065663dd0..cab20a3be 100644
--- a/protos/launcher_log.proto
+++ b/protos/launcher_log.proto
@@ -155,6 +155,7 @@ message Action {
CONFIRM = 4; // Indicates thata confirmation screen was accepted
STOP = 5; // Indicates onStop() was called (screen time out, power off)
RECENTS_BUTTON = 6; // Indicates that Recents button was pressed
+ RESUME = 7; // Indicates onResume() was called
}
optional Type type = 1;
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 9ab151231..c1f083d13 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -102,9 +102,11 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
public final void close(boolean animate) {
animate &= !Utilities.isPowerSaverPreventingAnimation(getContext());
+ if (mIsOpen) {
+ BaseActivity.fromContext(getContext()).getUserEventDispatcher()
+ .resetElapsedContainerMillis("container closed");
+ }
handleClose(animate);
- BaseActivity.fromContext(getContext()).getUserEventDispatcher()
- .resetElapsedContainerMillis("container closed");
mIsOpen = false;
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index e851499be..71ce8c42d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -50,6 +50,7 @@ import android.graphics.Point;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
import android.os.Parcelable;
import android.os.Process;
import android.os.StrictMode;
@@ -243,6 +244,10 @@ public class Launcher extends BaseDraggingActivity
private RotationHelper mRotationHelper;
+
+ private final Handler mHandler = new Handler();
+ private final Runnable mLogOnDelayedResume = this::logOnDelayedResume;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
if (DEBUG_STRICT_MODE) {
@@ -727,10 +732,11 @@ public class Launcher extends BaseDraggingActivity
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onStop();
}
- mAppWidgetHost.setListenIfResumed(false);
-
getUserEventDispatcher().logActionCommand(Action.Command.STOP,
mStateManager.getState().containerType, -1);
+
+ mAppWidgetHost.setListenIfResumed(false);
+
NotificationListener.removeNotificationsChangedListener();
getStateManager().moveToRestState();
@@ -751,13 +757,23 @@ public class Launcher extends BaseDraggingActivity
UiFactory.onStart(this);
}
+ private void logOnDelayedResume() {
+ if (hasBeenResumed()) {
+ getUserEventDispatcher().logActionCommand(Action.Command.RESUME,
+ mStateManager.getState().containerType, -1);
+ getUserEventDispatcher().startSession();
+ }
+ }
+
@Override
protected void onResume() {
TraceHelper.beginSection("ON_RESUME");
super.onResume();
TraceHelper.partitionSection("ON_RESUME", "superCall");
- getUserEventDispatcher().resetElapsedSessionMillis();
+ mHandler.removeCallbacks(mLogOnDelayedResume);
+ Utilities.postAsyncCallback(mHandler, mLogOnDelayedResume);
+
setOnResumeCallback(null);
// Process any items that were added while Launcher was away.
InstallShortcutReceiver.disableAndFlushInstallQueue(
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 850c948c2..1842e19a4 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -125,6 +125,7 @@ public class UserEventDispatcher {
return null;
}
+ private boolean mSessionStarted;
private long mElapsedContainerMillis;
private long mElapsedSessionMillis;
private long mActionDurationMillis;
@@ -216,9 +217,11 @@ public class UserEventDispatcher {
public void logActionCommand(int command, Target srcTarget, Target dstTarget) {
LauncherEvent event = newLauncherEvent(newCommandAction(command), srcTarget);
- if (command == Action.Command.STOP && mAppOrTaskLaunch) {
- // Prevent double logging by skipping STOP when app or task has been launched.
- return;
+ if (command == Action.Command.STOP) {
+ if (mAppOrTaskLaunch || !mSessionStarted) {
+ mSessionStarted = false;
+ return;
+ }
}
if (dstTarget != null) {
@@ -405,7 +408,8 @@ public class UserEventDispatcher {
}
- public final void resetElapsedSessionMillis() {
+ public final void startSession() {
+ mSessionStarted = true;
mElapsedSessionMillis = SystemClock.uptimeMillis();
mElapsedContainerMillis = SystemClock.uptimeMillis();
}