summaryrefslogtreecommitdiff
path: root/adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java
diff options
context:
space:
mode:
Diffstat (limited to 'adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java')
-rw-r--r--adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java137
1 files changed, 98 insertions, 39 deletions
diff --git a/adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java b/adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java
index 69454886b9..c409df4ef1 100644
--- a/adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java
+++ b/adservices/service-core/java/com/android/adservices/service/measurement/EventReport.java
@@ -21,6 +21,8 @@ import android.net.Uri;
import androidx.annotation.Nullable;
+import com.android.adservices.service.measurement.util.UnsignedLong;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -31,28 +33,42 @@ import java.util.Objects;
public class EventReport {
private String mId;
- private long mSourceId;
+ private UnsignedLong mSourceEventId;
private long mReportTime;
private long mTriggerTime;
private long mTriggerPriority;
private Uri mAttributionDestination;
private String mEnrollmentId;
- private long mTriggerData;
- private Long mTriggerDedupKey;
+ private UnsignedLong mTriggerData;
+ private UnsignedLong mTriggerDedupKey;
private double mRandomizedTriggerRate;
private @Status int mStatus;
+ private @DebugReportStatus int mDebugReportStatus;
private Source.SourceType mSourceType;
- @Nullable private Long mSourceDebugKey;
- @Nullable private Long mTriggerDebugKey;
+ @Nullable private UnsignedLong mSourceDebugKey;
+ @Nullable private UnsignedLong mTriggerDebugKey;
+ private String mSourceId;
+ private String mTriggerId;
- @IntDef(value = {
- Status.PENDING,
- Status.DELIVERED,
- })
+ @IntDef(value = {Status.PENDING, Status.DELIVERED, Status.MARKED_TO_DELETE})
@Retention(RetentionPolicy.SOURCE)
public @interface Status {
int PENDING = 0;
int DELIVERED = 1;
+ int MARKED_TO_DELETE = 2;
+ }
+
+ @IntDef(
+ value = {
+ DebugReportStatus.NONE,
+ DebugReportStatus.PENDING,
+ DebugReportStatus.DELIVERED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface DebugReportStatus {
+ int NONE = 0;
+ int PENDING = 1;
+ int DELIVERED = 2;
}
private EventReport() {
@@ -66,50 +82,52 @@ public class EventReport {
}
EventReport eventReport = (EventReport) obj;
return mStatus == eventReport.mStatus
+ && mDebugReportStatus == eventReport.mDebugReportStatus
&& mReportTime == eventReport.mReportTime
&& Objects.equals(mAttributionDestination, eventReport.mAttributionDestination)
&& Objects.equals(mEnrollmentId, eventReport.mEnrollmentId)
&& mTriggerTime == eventReport.mTriggerTime
- && mTriggerData == eventReport.mTriggerData
- && mSourceId == eventReport.mSourceId
+ && Objects.equals(mTriggerData, eventReport.mTriggerData)
+ && Objects.equals(mSourceEventId, eventReport.mSourceEventId)
&& mTriggerPriority == eventReport.mTriggerPriority
&& Objects.equals(mTriggerDedupKey, eventReport.mTriggerDedupKey)
&& mSourceType == eventReport.mSourceType
&& mRandomizedTriggerRate == eventReport.mRandomizedTriggerRate
&& Objects.equals(mSourceDebugKey, eventReport.mSourceDebugKey)
- && Objects.equals(mTriggerDebugKey, eventReport.mTriggerDebugKey);
+ && Objects.equals(mTriggerDebugKey, eventReport.mTriggerDebugKey)
+ && Objects.equals(mSourceId, eventReport.mSourceId)
+ && Objects.equals(mTriggerId, eventReport.mTriggerId);
}
@Override
public int hashCode() {
return Objects.hash(
mStatus,
+ mDebugReportStatus,
mReportTime,
mAttributionDestination,
mEnrollmentId,
mTriggerTime,
mTriggerData,
- mSourceId,
+ mSourceEventId,
mTriggerPriority,
mTriggerDedupKey,
mSourceType,
mRandomizedTriggerRate,
mSourceDebugKey,
- mTriggerDebugKey);
+ mTriggerDebugKey,
+ mSourceId,
+ mTriggerId);
}
- /**
- * Unique identifier for the report.
- */
+ /** Unique identifier for the report. */
public String getId() {
return mId;
}
- /**
- * Identifier of the associated {@link Source} event.
- */
- public long getSourceId() {
- return mSourceId;
+ /** Identifier of the associated {@link Source} event. */
+ public UnsignedLong getSourceEventId() {
+ return mSourceEventId;
}
/**
@@ -150,14 +168,14 @@ public class EventReport {
/**
* Metadata for the report.
*/
- public long getTriggerData() {
+ public UnsignedLong getTriggerData() {
return mTriggerData;
}
/**
* Deduplication key of the associated {@link Trigger}
*/
- public Long getTriggerDedupKey() {
+ public UnsignedLong getTriggerDedupKey() {
return mTriggerDedupKey;
}
@@ -168,6 +186,11 @@ public class EventReport {
return mStatus;
}
+ /** Current {@link DebugReportStatus} of the report. */
+ public @DebugReportStatus int getDebugReportStatus() {
+ return mDebugReportStatus;
+ }
+
/**
* SourceType of the event's source.
*/
@@ -184,16 +207,26 @@ public class EventReport {
/** Source Debug Key */
@Nullable
- public Long getSourceDebugKey() {
+ public UnsignedLong getSourceDebugKey() {
return mSourceDebugKey;
}
/** Trigger Debug Key */
@Nullable
- public Long getTriggerDebugKey() {
+ public UnsignedLong getTriggerDebugKey() {
return mTriggerDebugKey;
}
+ /** Source ID */
+ public String getSourceId() {
+ return mSourceId;
+ }
+
+ /** Trigger ID */
+ public String getTriggerId() {
+ return mTriggerId;
+ }
+
/** Builder for {@link EventReport} */
public static final class Builder {
@@ -211,11 +244,9 @@ public class EventReport {
return this;
}
- /**
- * See {@link EventReport#getSourceId()}
- */
- public Builder setSourceId(long sourceId) {
- mBuilding.mSourceId = sourceId;
+ /** See {@link EventReport#getSourceEventId()} */
+ public Builder setSourceEventId(UnsignedLong sourceEventId) {
+ mBuilding.mSourceEventId = sourceEventId;
return this;
}
@@ -246,7 +277,7 @@ public class EventReport {
/**
* See {@link EventReport#getTriggerData()}
*/
- public Builder setTriggerData(long triggerData) {
+ public Builder setTriggerData(UnsignedLong triggerData) {
mBuilding.mTriggerData = triggerData;
return this;
}
@@ -262,7 +293,7 @@ public class EventReport {
/**
* See {@link EventReport#getTriggerDedupKey()}
*/
- public Builder setTriggerDedupKey(Long triggerDedupKey) {
+ public Builder setTriggerDedupKey(UnsignedLong triggerDedupKey) {
mBuilding.mTriggerDedupKey = triggerDedupKey;
return this;
}
@@ -283,6 +314,12 @@ public class EventReport {
return this;
}
+ /** See {@link EventReport#getDebugReportStatus()} ()} */
+ public Builder setDebugReportStatus(@DebugReportStatus int debugReportStatus) {
+ mBuilding.mDebugReportStatus = debugReportStatus;
+ return this;
+ }
+
/**
* See {@link EventReport#getSourceType()}
*/
@@ -300,17 +337,29 @@ public class EventReport {
}
/** See {@link EventReport#getSourceDebugKey()} ()} */
- public Builder setSourceDebugKey(Long sourceDebugKey) {
+ public Builder setSourceDebugKey(UnsignedLong sourceDebugKey) {
mBuilding.mSourceDebugKey = sourceDebugKey;
return this;
}
/** See {@link EventReport#getTriggerDebugKey()} ()} */
- public Builder setTriggerDebugKey(Long triggerDebugKey) {
+ public Builder setTriggerDebugKey(UnsignedLong triggerDebugKey) {
mBuilding.mTriggerDebugKey = triggerDebugKey;
return this;
}
+ /** See {@link EventReport#getSourceId()} */
+ public Builder setSourceId(String sourceId) {
+ mBuilding.mSourceId = sourceId;
+ return this;
+ }
+
+ /** See {@link EventReport#getTriggerId()} */
+ public Builder setTriggerId(String triggerId) {
+ mBuilding.mTriggerId = triggerId;
+ return this;
+ }
+
/** Populates fields using {@link Source}, {@link Trigger} and {@link EventTrigger}. */
public Builder populateFromSourceAndTrigger(
Source source, Trigger trigger, EventTrigger eventTrigger) {
@@ -319,23 +368,33 @@ public class EventReport {
// truncate trigger data to 3-bit or 1-bit based on {@link Source.SourceType}
mBuilding.mTriggerData = getTruncatedTriggerData(source, eventTrigger);
mBuilding.mTriggerTime = trigger.getTriggerTime();
- mBuilding.mSourceId = source.getEventId();
+ mBuilding.mSourceEventId = source.getEventId();
mBuilding.mEnrollmentId = source.getEnrollmentId();
mBuilding.mStatus = Status.PENDING;
- mBuilding.mAttributionDestination = trigger.getAttributionDestination();
+ mBuilding.mAttributionDestination = trigger.getAttributionDestinationBaseUri();
mBuilding.mReportTime =
source.getReportingTime(
trigger.getTriggerTime(),
trigger.getDestinationType());
mBuilding.mSourceType = source.getSourceType();
mBuilding.mRandomizedTriggerRate = source.getRandomAttributionProbability();
+ mBuilding.mDebugReportStatus = DebugReportStatus.NONE;
+ if (source.getDebugKey() != null || trigger.getDebugKey() != null) {
+ mBuilding.mDebugReportStatus = DebugReportStatus.PENDING;
+ }
mBuilding.mSourceDebugKey = source.getDebugKey();
mBuilding.mTriggerDebugKey = trigger.getDebugKey();
+ mBuilding.mSourceId = source.getId();
+ mBuilding.mTriggerId = trigger.getId();
return this;
}
- private long getTruncatedTriggerData(Source source, EventTrigger eventTrigger) {
- return eventTrigger.getTriggerData() % source.getTriggerDataCardinality();
+ private UnsignedLong getTruncatedTriggerData(Source source, EventTrigger eventTrigger) {
+ UnsignedLong triggerData = eventTrigger.getTriggerData();
+ if (triggerData == null) {
+ return new UnsignedLong(0L);
+ }
+ return triggerData.mod(source.getTriggerDataCardinality());
}
/**