Merge "Add RankingSelected to UiEventLogger." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c66aeed213
@@ -60,4 +60,28 @@ public interface UiEventLogger {
|
||||
*/
|
||||
void logWithInstanceId(@NonNull UiEventEnum event, int uid, @Nullable String packageName,
|
||||
@Nullable InstanceId instance);
|
||||
|
||||
/**
|
||||
* Log an event with ranked-choice information along with package.
|
||||
* Does nothing if event.getId() <= 0.
|
||||
* @param event an enum implementing UiEventEnum interface.
|
||||
* @param uid the uid of the relevant app, if known (0 otherwise).
|
||||
* @param packageName the package name of the relevant app, if known (null otherwise).
|
||||
* @param position the position picked.
|
||||
*/
|
||||
void logWithPosition(@NonNull UiEventEnum event, int uid, @Nullable String packageName,
|
||||
int position);
|
||||
|
||||
/**
|
||||
* Log an event with ranked-choice information along with package and instance ID.
|
||||
* Does nothing if event.getId() <= 0.
|
||||
* @param event an enum implementing UiEventEnum interface.
|
||||
* @param uid the uid of the relevant app, if known (0 otherwise).
|
||||
* @param packageName the package name of the relevant app, if known (null otherwise).
|
||||
* @param instance An identifier obtained from an InstanceIdSequence. If null, reduces to
|
||||
* logWithPosition().
|
||||
* @param position the position picked.
|
||||
*/
|
||||
void logWithInstanceIdAndPosition(@NonNull UiEventEnum event, int uid,
|
||||
@Nullable String packageName, @Nullable InstanceId instance, int position);
|
||||
}
|
||||
|
||||
@@ -48,4 +48,31 @@ public class UiEventLoggerImpl implements UiEventLogger {
|
||||
log(event, uid, packageName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWithPosition(UiEventEnum event, int uid, String packageName, int position) {
|
||||
final int eventID = event.getId();
|
||||
if (eventID > 0) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.RANKING_SELECTED,
|
||||
/* event_id = 1 */ eventID,
|
||||
/* package_name = 2 */ packageName,
|
||||
/* instance_id = 3 */ 0,
|
||||
/* position_picked = 4 */ position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWithInstanceIdAndPosition(UiEventEnum event, int uid, String packageName,
|
||||
InstanceId instance, int position) {
|
||||
final int eventID = event.getId();
|
||||
if ((eventID > 0) && (instance != null)) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.RANKING_SELECTED,
|
||||
/* event_id = 1 */ eventID,
|
||||
/* package_name = 2 */ packageName,
|
||||
/* instance_id = 3 */ instance.getId(),
|
||||
/* position_picked = 4 */ position);
|
||||
} else {
|
||||
logWithPosition(event, uid, packageName, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,15 @@ public class UiEventLoggerFake implements UiEventLogger {
|
||||
public final int eventId;
|
||||
public final int uid;
|
||||
public final String packageName;
|
||||
public final InstanceId instanceId; // Used only for WithInstanceId variant
|
||||
public final InstanceId instanceId; // Used only for WithInstanceId variants
|
||||
public final int position; // Used only for Position variants
|
||||
|
||||
FakeUiEvent(int eventId, int uid, String packageName) {
|
||||
this.eventId = eventId;
|
||||
this.uid = uid;
|
||||
this.packageName = packageName;
|
||||
this.instanceId = null;
|
||||
this.position = 0;
|
||||
}
|
||||
|
||||
FakeUiEvent(int eventId, int uid, String packageName, InstanceId instanceId) {
|
||||
@@ -49,6 +51,15 @@ public class UiEventLoggerFake implements UiEventLogger {
|
||||
this.uid = uid;
|
||||
this.packageName = packageName;
|
||||
this.instanceId = instanceId;
|
||||
this.position = 0;
|
||||
}
|
||||
|
||||
FakeUiEvent(int eventId, int uid, String packageName, InstanceId instanceId, int position) {
|
||||
this.eventId = eventId;
|
||||
this.uid = uid;
|
||||
this.packageName = packageName;
|
||||
this.instanceId = instanceId;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,4 +103,21 @@ public class UiEventLoggerFake implements UiEventLogger {
|
||||
mLogs.add(new FakeUiEvent(eventId, uid, packageName, instance));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWithPosition(UiEventEnum event, int uid, String packageName, int position) {
|
||||
final int eventId = event.getId();
|
||||
if (eventId > 0) {
|
||||
mLogs.add(new FakeUiEvent(eventId, uid, packageName, null, position));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWithInstanceIdAndPosition(UiEventEnum event, int uid, String packageName,
|
||||
InstanceId instance, int position) {
|
||||
final int eventId = event.getId();
|
||||
if (eventId > 0) {
|
||||
mLogs.add(new FakeUiEvent(eventId, uid, packageName, instance, position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user