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

Commit c96873ca authored by thiruram's avatar thiruram Committed by Thiru Ramasamy
Browse files

[AA+] Log LAUNCHER_ONSTOP & LAUNCHER_ONRESUME events with AllApps session InstanceId.

* Transitions between AllApps and App screen logs LAUNCHER_ONSTOP & LAUNCHER_ONRESUME events. This change add InstanceId specific to the current AllApps session to these logs; this will help to regenerate AllApps session from logs on the server side. This should only affect logs from AllApps screen, but not others.

* Removes LiveSearchManager.allAppsLogger method as it may create confusion with 2 methods for logging into Statsd

* Moved AllApps entry and exit logs to Launcher.

Bug: 178562918
Test: Manual
Change-Id: I5fab941777a3dfd2e9b19c0efd5b06d3884222ef
parent c860448b
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;

public class QuickstepLauncher extends BaseQuickstepLauncher {
@@ -106,10 +105,9 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
    protected void logAppLaunch(ItemInfo info, InstanceId instanceId) {
        // If the app launch is from any of the surfaces in AllApps then add the InstanceId from
        // LiveSearchManager to recreate the AllApps session on the server side.
        Optional<InstanceId> logInstanceId = this.getLiveSearchManager().getLogInstanceId();
        if (logInstanceId.isPresent() && ALL_APPS.equals(
        if (mAllAppsSessionLogId != null && ALL_APPS.equals(
                getStateManager().getCurrentStableState())) {
            instanceId = logInstanceId.get();
            instanceId = mAllAppsSessionLogId;
        }

        StatsLogger logger = getStatsLogManager()
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class StatsLogCompatManager extends StatsLogManager {
    }

    @Override
    public StatsLogger logger() {
    protected StatsLogger createLogger() {
        return new StatsCompatLogger();
    }

+4 −1
Original line number Diff line number Diff line
@@ -141,7 +141,10 @@ public abstract class BaseActivity extends Activity implements ActivityContext {
        return mDeviceProfile;
    }

    public final StatsLogManager getStatsLogManager() {
    /**
     * Returns {@link StatsLogManager} for user event logging.
     */
    public StatsLogManager getStatsLogManager() {
        if (mStatsLogManager == null) {
            mStatsLogManager = StatsLogManager.newInstance(this);
        }
+28 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ENTRY;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_EXIT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONRESUME;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ONSTOP;
import static com.android.launcher3.model.ItemInstallQueue.FLAG_ACTIVITY_PAUSED;
@@ -124,6 +126,8 @@ import com.android.launcher3.keyboard.CustomActionsPopup;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.model.ItemInstallQueue;
@@ -352,6 +356,13 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche

    private SafeCloseable mUserChangedCallbackCloseable;

    // New InstanceId is assigned to mAllAppsSessionLogId for each AllApps sessions.
    // When Launcher is not in AllApps state mAllAppsSessionLogId will be null.
    // User actions within AllApps state are logged with this InstanceId, to recreate AllApps
    // session on the server side.
    protected InstanceId mAllAppsSessionLogId;
    private LauncherState mPrevLauncherState;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Object traceToken = TraceHelper.INSTANCE.beginSection(ON_CREATE_EVT,
@@ -1027,6 +1038,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        }
        // When multiple pages are visible, show persistent page indicator
        mWorkspace.getPageIndicator().setShouldAutoHide(!state.hasFlag(FLAG_MULTI_PAGE));
        mPrevLauncherState = mStateManager.getCurrentStableState();
    }

    @Override
@@ -1050,6 +1062,17 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
            // Clear any rotation locks when going to normal state
            getRotationHelper().setCurrentStateRequest(REQUEST_NONE);
        }

        if (ALL_APPS.equals(state)) {
            // creates new instance ID since new all apps session is started.
            mAllAppsSessionLogId = new InstanceIdSequence().newInstanceId();
            getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_ENTRY);
        } else if (ALL_APPS.equals(mPrevLauncherState)
                // Check if mLogInstanceId is not null to make sure exit event is logged only once.
                && mAllAppsSessionLogId != null) {
            getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_EXIT);
            mAllAppsSessionLogId = null;
        }
    }

    @Override
@@ -2818,4 +2841,9 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        public Configuration config;
        public Bitmap snapshot;
    }

    @Override
    public StatsLogManager getStatsLogManager() {
        return super.getStatsLogManager().withDefaultInstanceId(mAllAppsSessionLogId);
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -90,10 +90,9 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
    public void onTabChanged(int pos) {
        super.onTabChanged(pos);
        if (mUsingTabs) {

            // Log tab switches only when the launcher is in AllApps state
            if (mLauncher.getStateManager().getCurrentStableState() == LauncherState.ALL_APPS) {
                mLauncher.getLiveSearchManager().allAppsLogger()
                mLauncher.getStatsLogManager().logger()
                        .log(pos == AdapterHolder.WORK ? LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB
                                : LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB);
            }
@@ -109,6 +108,6 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView {
    @Override
    protected void hideIme() {
        super.hideIme();
        mLauncher.getLiveSearchManager().allAppsLogger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED);
        mLauncher.getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED);
    }
}
Loading