1 /*
2  * Copyright (C) 2023 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.signals;
18 
19 import com.google.auto.value.AutoValue;
20 
21 import java.time.Instant;
22 
23 /** Internal representation of a custom protected signal's value and metadata. */
24 @AutoValue
25 public abstract class ProtectedSignal {
26 
27     // 60 days
28     public static final int EXPIRATION_SECONDS = 60 * 24 * 60 * 60;
29 
30     /**
31      * @return The value of this signal in the form of base 64 encoded string
32      */
getBase64EncodedValue()33     public abstract String getBase64EncodedValue();
34 
35     /**
36      * @return The time the signal was creation
37      */
getCreationTime()38     public abstract Instant getCreationTime();
39 
40     /**
41      * @return The package name that created the signal.
42      */
getPackageName()43     public abstract String getPackageName();
44 
builder()45     static Builder builder() {
46         return new AutoValue_ProtectedSignal.Builder();
47     }
48 
49     @AutoValue.Builder
50     abstract static class Builder {
setBase64EncodedValue(String value)51         abstract Builder setBase64EncodedValue(String value);
52 
setCreationTime(Instant creationTime)53         abstract Builder setCreationTime(Instant creationTime);
54 
setPackageName(String packageName)55         abstract Builder setPackageName(String packageName);
56 
build()57         abstract ProtectedSignal build();
58     }
59 }
60