1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.adservices.service.measurement;
18 
19 import com.android.adservices.service.Flags;
20 
21 import java.util.concurrent.TimeUnit;
22 
23 /**
24  * Class for holding privacy related parameters.
25  * All values in this class are temporary and subject to change based on feedback and testing.
26  */
27 public final class PrivacyParams {
28 
29     /**
30      * Max reports for 'Navigation' {@link Source}.
31      */
32     public static final int NAVIGATION_SOURCE_MAX_REPORTS = 3;
33 
34     /**
35      * Max reports for 'Event' {@link Source}.
36      */
37     public static final int EVENT_SOURCE_MAX_REPORTS = 1;
38 
39     /**
40      * Max reports for Install Attributed 'Event' {@link Source}.
41      */
42     public static final int INSTALL_ATTR_EVENT_SOURCE_MAX_REPORTS = 2;
43 
44     /**
45      * Rate limit window for (Source Site, Destination Site, Reporting Site, Window) privacy unit.
46      * 30 days.
47      */
48     public static final long RATE_LIMIT_WINDOW_MILLISECONDS = TimeUnit.DAYS.toMillis(30);
49 
50     /**
51      * Early reporting window for 'Navigation' {@link Source}.
52      * 2 days and 7 days.
53      */
54     public static final long[] NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS = new long[]{
55             TimeUnit.DAYS.toMillis(2), TimeUnit.DAYS.toMillis(7)
56     };
57 
58     /**
59      * Early reporting window for 'Event' {@link Source}.
60      * No windows.
61      */
62     public static final long[] EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS = new long[]{ };
63 
64     /**
65      * Early reporting window for Install Attributed 'Navigation' {@link Source}. 2 days and 7 days.
66      */
67     public static final long[] INSTALL_ATTR_NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS =
68             NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS;
69 
70     /**
71      * Early reporting window for Install Attributed 'Event' {@link Source}.
72      * 2 days.
73      */
74     public static final long[] INSTALL_ATTR_EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS =
75             new long[]{ TimeUnit.DAYS.toMillis(2) };
76 
77 
78     /**
79      * Trigger data cardinality for 'Event' {@link Source} attribution.
80      */
81     public static final int EVENT_TRIGGER_DATA_CARDINALITY = 2;
82 
83     /**
84      * Trigger data cardinality for 'Navigation' {@link Source} attribution.
85      */
86     private static final int NAVIGATION_TRIGGER_DATA_CARDINALITY = 8;
87 
getNavigationTriggerDataCardinality()88     public static int getNavigationTriggerDataCardinality() {
89         return NAVIGATION_TRIGGER_DATA_CARDINALITY;
90     }
91 
92     /**
93      * L1, the maximum sum of the contributions (values) across all buckets for a given source
94      * event.
95      */
96     public static final int MAX_SUM_OF_AGGREGATE_VALUES_PER_SOURCE = 65536;
97 
98     /** Amount of bytes allocated for aggregate histogram bucket */
99     public static final int AGGREGATE_HISTOGRAM_BUCKET_BYTE_SIZE = 16;
100 
101     /** Amount of bytes allocated for aggregate histogram value */
102     public static final int AGGREGATE_HISTOGRAM_VALUE_BYTE_SIZE = 4;
103 
104     /** Minimum time an aggregate report is delayed after trigger */
105     public static final long AGGREGATE_REPORT_MIN_DELAY = TimeUnit.MINUTES.toMillis(0L);
106 
107     /** Maximum time an aggregate report is delayed after trigger */
108     public static final long AGGREGATE_REPORT_DELAY_SPAN = TimeUnit.MINUTES.toMillis(10L);
109     public static final double NUMBER_EQUAL_THRESHOLD = 0.0000001D;
110 
111     /**
112      * Maximum early reporting windows configured through {@link
113      * Flags#MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS} or {@link
114      * Flags#MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS}.
115      */
116     public static final int MAX_CONFIGURABLE_EVENT_REPORT_EARLY_REPORTING_WINDOWS = 2;
117 
PrivacyParams()118     private PrivacyParams() {
119     }
120 }
121