Add logs for taskbar and overview split action
Log: - Taskbar app launch (also from foldeR) - Taskbar app drag (also from folder) - Taskbar folder open - Long press to hide taskbar - Long press to show taskbar - Overview Split screen action Also add support for ActivityContext to overwrite/add to LauncherAtom.ItemInfo, which TaskbarActivityContext does to change HotseatContainer and PredictedHotseatContainer to TaskBarContainer Test: enable logcat locally Bug: 193009817 Change-Id: Ia82c846a727fecb8cbfd0a069c8af1276083bf83
This commit is contained in:
1 parent
be8b2ad03d
commit
2a10e62e92
11 files changed
+157
-17
No files matched your search
@@ -55,6 +55,7 @@ import com.android.launcher3.allapps.search.DefaultSearchAdapterProvider;
|
||||
import com.android.launcher3.allapps.search.SearchAdapterProvider;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.InstanceIdSequence;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
@@ -224,7 +225,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
}
|
||||
if (item != null) {
|
||||
InstanceId instanceId = new InstanceIdSequence().newInstanceId();
|
||||
logAppLaunch(item, instanceId);
|
||||
logAppLaunch(getStatsLogManager(), item, instanceId);
|
||||
}
|
||||
return true;
|
||||
} catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
|
||||
@@ -234,8 +235,12 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void logAppLaunch(ItemInfo info, InstanceId instanceId) {
|
||||
getStatsLogManager().logger().withItemInfo(info).withInstanceId(instanceId)
|
||||
/**
|
||||
* Creates and logs a new app launch event.
|
||||
*/
|
||||
public void logAppLaunch(StatsLogManager statsLogManager, ItemInfo info,
|
||||
InstanceId instanceId) {
|
||||
statsLogManager.logger().withItemInfo(info).withInstanceId(instanceId)
|
||||
.log(LAUNCHER_APP_LAUNCH_TAP);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ import androidx.annotation.VisibleForTesting;
|
||||
*/
|
||||
public final class InstanceId implements Parcelable {
|
||||
// At most 20 bits: ~1m possibilities, ~0.5% probability of collision in 100 values
|
||||
static final int INSTANCE_ID_MAX = 1 << 20;
|
||||
public static final int INSTANCE_ID_MAX = 1 << 20;
|
||||
|
||||
private final int mId;
|
||||
InstanceId(int id) {
|
||||
public InstanceId(int id) {
|
||||
mId = min(max(0, id), INSTANCE_ID_MAX);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.android.launcher3.logger.LauncherAtom.FromState;
|
||||
import com.android.launcher3.logger.LauncherAtom.ToState;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
/**
|
||||
* Handles the user event logging in R+.
|
||||
@@ -53,6 +54,9 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
public static final int LAUNCHER_STATE_UNCHANGED = 5;
|
||||
|
||||
private InstanceId mInstanceId;
|
||||
|
||||
protected @Nullable ActivityContext mActivityContext = null;
|
||||
|
||||
/**
|
||||
* Returns event enum based on the two state transition information when swipe
|
||||
* gesture happens(to be removed during UserEventDispatcher cleanup).
|
||||
@@ -281,6 +285,9 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
@UiEvent(doc = "User tapped on the share button on overview")
|
||||
LAUNCHER_OVERVIEW_ACTIONS_SHARE(582),
|
||||
|
||||
@UiEvent(doc = "User tapped on the split screen button on overview")
|
||||
LAUNCHER_OVERVIEW_ACTIONS_SPLIT(895),
|
||||
|
||||
@UiEvent(doc = "User tapped on the close button in select mode")
|
||||
LAUNCHER_SELECT_MODE_CLOSE(583),
|
||||
|
||||
@@ -505,7 +512,13 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
LAUNCHER_TURN_OFF_WORK_APPS_TAP(839),
|
||||
|
||||
@UiEvent(doc = "Launcher item drop failed since there was not enough room on the screen.")
|
||||
LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872);
|
||||
LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872),
|
||||
|
||||
@UiEvent(doc = "User long pressed on the taskbar background to hide the taskbar")
|
||||
LAUNCHER_TASKBAR_LONGPRESS_HIDE(896),
|
||||
|
||||
@UiEvent(doc = "User long pressed on the taskbar gesture handle to show the taskbar")
|
||||
LAUNCHER_TASKBAR_LONGPRESS_SHOW(897);
|
||||
|
||||
// ADD MORE
|
||||
|
||||
@@ -645,7 +658,7 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
public StatsLogger logger() {
|
||||
StatsLogger logger = createLogger();
|
||||
if (mInstanceId != null) {
|
||||
return logger.withInstanceId(mInstanceId);
|
||||
logger.withInstanceId(mInstanceId);
|
||||
}
|
||||
return logger;
|
||||
}
|
||||
@@ -668,7 +681,9 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
* Creates a new instance of {@link StatsLogManager} based on provided context.
|
||||
*/
|
||||
public static StatsLogManager newInstance(Context context) {
|
||||
return Overrides.getObject(StatsLogManager.class,
|
||||
StatsLogManager manager = Overrides.getObject(StatsLogManager.class,
|
||||
context.getApplicationContext(), R.string.stats_log_manager_class);
|
||||
manager.mActivityContext = ActivityContext.lookupContextNoThrow(context);
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.dot.DotInfo;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.folder.FolderIcon;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.ViewCache;
|
||||
@@ -122,15 +123,33 @@ public interface ActivityContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityContext associated with the given Context.
|
||||
* Called just before logging the given item.
|
||||
*/
|
||||
default void applyOverwritesToLogItem(LauncherAtom.ItemInfo.Builder itemInfoBuilder) { }
|
||||
|
||||
/**
|
||||
* Returns the ActivityContext associated with the given Context, or throws an exception if
|
||||
* the Context is not associated with any ActivityContext.
|
||||
*/
|
||||
static <T extends Context & ActivityContext> T lookupContext(Context context) {
|
||||
T activityContext = lookupContextNoThrow(context);
|
||||
if (activityContext == null) {
|
||||
throw new IllegalArgumentException("Cannot find ActivityContext in parent tree");
|
||||
}
|
||||
return activityContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ActivityContext associated with the given Context, or null if
|
||||
* the Context is not associated with any ActivityContext.
|
||||
*/
|
||||
static <T extends Context & ActivityContext> T lookupContextNoThrow(Context context) {
|
||||
if (context instanceof ActivityContext) {
|
||||
return (T) context;
|
||||
} else if (context instanceof ContextWrapper) {
|
||||
return lookupContext(((ContextWrapper) context).getBaseContext());
|
||||
return lookupContextNoThrow(((ContextWrapper) context).getBaseContext());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Cannot find ActivityContext in parent tree");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user