Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8fd5e938 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Add getUserEventLogger to LauncherCallbacks

b/26494415

Change-Id: I8abaaf1269c12435a523e31bf769991018ea5c02
parent 726eb822
Loading
Loading
Loading
Loading
+36 −7
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
@@ -109,8 +108,10 @@ import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logging.UserEventLogger;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.userevent.Logger;
import com.android.launcher3.logging.LoggerUtils;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.TestingUtils;
@@ -131,6 +132,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;

/**
 * Default launcher application.
@@ -366,7 +368,7 @@ public class Launcher extends Activity
    }

    private Stats mStats;
    private Logger mUserEventLogger;
    private UserEventLogger mUserEventLogger;

    public FocusIndicatorView mFocusHandler;
    private boolean mRotationEnabled = false;
@@ -425,8 +427,8 @@ public class Launcher extends Activity
        mDragController = new DragController(this);
        mStateTransitionAnimation = new LauncherStateTransitionAnimation(this);

        mUserEventLogger = new Logger(this);
        mStats = new Stats(this);
        initLogger();

        mAppWidgetManager = AppWidgetManagerCompat.getInstance(this);

@@ -632,7 +634,35 @@ public class Launcher extends Activity
    public Stats getStats() {
        return mStats;
    }
    public Logger getLogger() {return mUserEventLogger; }

    /**
     * Logger object is a singleton and does not have to be coupled with the foreground activity.
     * Since most user event logging is done on the UI, the object is retrieved from the
     * callback for convenience.
     */
    private void initLogger() {
        if (mLauncherCallbacks != null) {
            mUserEventLogger = mLauncherCallbacks.getLogger();
        }
        if (mUserEventLogger == null) {
            mUserEventLogger = new UserEventLogger() {
                @Override
                public void processEvent(LauncherLogProto.LauncherEvent ev) {
                    if (ev.action.touch == LauncherLogProto.Action.TAP && ev.srcTarget.itemType == LauncherLogProto.APP_ICON) {
                        Log.d(TAG, String.format(Locale.US, "action:%s target:%s\n\telapsed container %d ms session %d ms",
                                LoggerUtils.getActionStr(ev.action),
                                LoggerUtils.getTargetStr(ev.srcTarget),
                                ev.elapsedContainerMillis,
                                ev.elapsedSessionMillis));
                    }
                }
            };
        }
    }

    public UserEventLogger getLogger() {
        return mUserEventLogger;
    }

    public boolean isDraggingEnabled() {
        // We prevent dragging when we are loading the workspace as it is possible to pick up a view
@@ -3302,7 +3332,6 @@ public class Launcher extends Activity
            getWindow().getDecorView()
                    .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
        mUserEventLogger.resetElapsedContainerMillis();
        return changed;
    }

+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import com.android.launcher3.allapps.AllAppsSearchBarController;
import com.android.launcher3.logging.UserEventLogger;
import com.android.launcher3.util.ComponentKey;

import java.io.FileDescriptor;
@@ -97,6 +98,7 @@ public interface LauncherCallbacks {
    /*
     * Extensions points for adding / replacing some other aspects of the Launcher experience.
     */
    public UserEventLogger getLogger();
    public Intent getFirstRunActivity();
    public boolean hasFirstRunActivity();
    public boolean hasDismissableIntroScreen();
+15 −1
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ public class LauncherStateTransitionAnimation {
            }
            @Override
            void onTransitionComplete() {
                mLauncher.getLogger().resetElapsedContainerMillis();
                if (startSearchAfterTransition) {
                    toView.startAppsSearch();
                }
@@ -167,7 +168,12 @@ public class LauncherStateTransitionAnimation {
        final View buttonView = mLauncher.getWidgetsButton();
        mCurrentAnimation = startAnimationToOverlay(fromWorkspaceState,
                Workspace.State.OVERVIEW_HIDDEN, buttonView, toView, animated,
                new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS));
                new PrivateTransitionCallbacks(FINAL_REVEAL_ALPHA_FOR_WIDGETS){
                    @Override
                    void onTransitionComplete() {
                        mLauncher.getLogger().resetElapsedContainerMillis();
                    }
                });
    }

    /**
@@ -462,6 +468,10 @@ public class LauncherStateTransitionAnimation {
                    }
                };
            }
            @Override
            void onTransitionComplete() {
                mLauncher.getLogger().resetElapsedContainerMillis();
            }
        };
        // Only animate the search bar if animating to spring loaded mode from all apps
        mCurrentAnimation = startAnimationToWorkspaceFromOverlay(fromWorkspaceState, toWorkspaceState,
@@ -488,6 +498,10 @@ public class LauncherStateTransitionAnimation {
                    }
                };
            }
            @Override
            void onTransitionComplete() {
                mLauncher.getLogger().resetElapsedContainerMillis();
            }
        };
        mCurrentAnimation = startAnimationToWorkspaceFromOverlay(
                fromWorkspaceState, toWorkspaceState,
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.view.View;
import android.view.ViewParent;

import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.userevent.Logger;

public class Stats {

+0 −2
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import com.android.launcher3.LauncherTransitionable;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.userevent.Logger;
import com.android.launcher3.util.ComponentKey;

import java.nio.charset.Charset;
@@ -313,7 +312,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
                icon.getMeasuredHeight());

        updateBackgroundAndPaddings();
        mLauncher.getLogger().resetElapsedContainerMillis();
    }

    @Override
Loading