Merge "Implement ImpressionLogging v2." into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4cd4ed090e
@@ -62,14 +62,11 @@ import com.android.launcher3.model.BgDataModel;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.LogConfig;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
|
||||
import com.android.systemui.shared.system.SysUiStatsLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -564,14 +561,16 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
* Helps to construct and log statsd compatible impression events.
|
||||
*/
|
||||
private static class StatsCompatImpressionLogger implements StatsImpressionLogger {
|
||||
private int[] mResultTypeList = new int[]{};
|
||||
private int[] mResultCountList = new int[]{};
|
||||
private final List<Boolean> mAboveKeyboardList = new ArrayList<>();
|
||||
private int[] mUidList = new int[]{};
|
||||
private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
|
||||
private State mLauncherState = State.UNKNOWN;
|
||||
private int mQueryLength = -1;
|
||||
|
||||
// Fields used for Impression Logging V2.
|
||||
private int mResultType;
|
||||
private boolean mAboveKeyboard = false;
|
||||
private int mUid;
|
||||
private int mResultSource;
|
||||
|
||||
@Override
|
||||
public StatsImpressionLogger withInstanceId(InstanceId instanceId) {
|
||||
this.mInstanceId = instanceId;
|
||||
@@ -591,69 +590,60 @@ public class StatsLogCompatManager extends StatsLogManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatsImpressionLogger withResultType(IntArray resultType) {
|
||||
mResultTypeList = resultType.toArray();
|
||||
public StatsImpressionLogger withResultType(int resultType) {
|
||||
mResultType = resultType;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StatsImpressionLogger withAboveKeyboard(boolean aboveKeyboard) {
|
||||
mAboveKeyboard = aboveKeyboard;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatsImpressionLogger withResultCount(IntArray resultCount) {
|
||||
mResultCountList = resultCount.toArray();
|
||||
public StatsImpressionLogger withUid(int uid) {
|
||||
mUid = uid;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatsImpressionLogger withAboveKeyboard(List<Boolean> aboveKeyboard) {
|
||||
mAboveKeyboardList.clear();
|
||||
this.mAboveKeyboardList.addAll(aboveKeyboard);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatsImpressionLogger withUids(IntArray uid) {
|
||||
mUidList = uid.toArray();
|
||||
public StatsImpressionLogger withResultSource(int resultSource) {
|
||||
mResultSource = resultSource;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(EventEnum event) {
|
||||
boolean[] mAboveKeyboard = new boolean[mAboveKeyboardList.size()];
|
||||
for (int i = 0; i < mAboveKeyboardList.size(); i++) {
|
||||
mAboveKeyboard[i] = mAboveKeyboardList.get(i);
|
||||
}
|
||||
if (IS_VERBOSE) {
|
||||
String name = (event instanceof Enum) ? ((Enum) event).name() :
|
||||
event.getId() + "";
|
||||
StringBuilder logStringBuilder = new StringBuilder("\n");
|
||||
logStringBuilder.append(String.format("InstanceId:%s ", mInstanceId));
|
||||
logStringBuilder.append(String.format("ImpressionEvent:%s ", name));
|
||||
logStringBuilder.append(String.format("LauncherState = %s ", mLauncherState));
|
||||
logStringBuilder.append(String.format("QueryLength = %s ", mQueryLength));
|
||||
for (int i = 0; i < mResultTypeList.length; i++) {
|
||||
logStringBuilder.append(String.format(
|
||||
"\n ResultType = %s with ResultCount = %s with is_above_keyboard = %s"
|
||||
+ " with uid = %s",
|
||||
mResultTypeList[i], mResultCountList[i],
|
||||
mAboveKeyboard[i], mUidList[i]));
|
||||
}
|
||||
logStringBuilder.append(String.format("\n\tLauncherState = %s ", mLauncherState));
|
||||
logStringBuilder.append(String.format("\tQueryLength = %s ", mQueryLength));
|
||||
logStringBuilder.append(String.format(
|
||||
"\n\t ResultType = %s is_above_keyboard = %s"
|
||||
+ " uid = %s result_source = %s",
|
||||
mResultType,
|
||||
mAboveKeyboard, mUid, mResultSource));
|
||||
|
||||
Log.d(IMPRESSION_TAG, logStringBuilder.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_IMPRESSION_EVENT,
|
||||
SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_IMPRESSION_EVENT_V2,
|
||||
event.getId(), // event_id
|
||||
mInstanceId.getId(), // instance_id
|
||||
mLauncherState.getLauncherState(), // state
|
||||
mQueryLength, // query_length
|
||||
//result type list
|
||||
mResultTypeList,
|
||||
// result count list
|
||||
mResultCountList,
|
||||
// above keyboard list
|
||||
mAboveKeyboard,
|
||||
// uid list
|
||||
mUidList
|
||||
mResultType, //result type
|
||||
mAboveKeyboard, // above keyboard
|
||||
mUid, // uid
|
||||
mResultSource // result source
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,9 @@ import com.android.launcher3.logger.LauncherAtom.ContainerInfo;
|
||||
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.IntArray;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles the user event logging in R+.
|
||||
*
|
||||
@@ -961,33 +958,32 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets list of {@link com.android.app.search.ResultType} for the impression event.
|
||||
* Sets {@link com.android.app.search.ResultType} for the impression event.
|
||||
*/
|
||||
default StatsImpressionLogger withResultType(IntArray resultType) {
|
||||
default StatsImpressionLogger withResultType(int resultType) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets list of count for each of {@link com.android.app.search.ResultType} for the
|
||||
* impression event.
|
||||
*/
|
||||
default StatsImpressionLogger withResultCount(IntArray resultCount) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets list of boolean for each of {@link com.android.app.search.ResultType} that indicates
|
||||
* Sets boolean for each of {@link com.android.app.search.ResultType} that indicates
|
||||
* if this result is above keyboard or not for the impression event.
|
||||
*/
|
||||
default StatsImpressionLogger withAboveKeyboard(List<Boolean> aboveKeyboard) {
|
||||
default StatsImpressionLogger withAboveKeyboard(boolean aboveKeyboard) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets list of uid for each of {@link com.android.app.search.ResultType} that indicates
|
||||
* Sets uid for each of {@link com.android.app.search.ResultType} that indicates
|
||||
* package name for the impression event.
|
||||
*/
|
||||
default StatsImpressionLogger withUids(IntArray uid) {
|
||||
default StatsImpressionLogger withUid(int uid) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets result source that indicates the origin of the result for the impression event.
|
||||
*/
|
||||
default StatsImpressionLogger withResultSource(int resultSource) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user