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.consent;
18 
19 import com.android.adservices.service.common.compat.FileCompatUtils;
20 
21 /** ConsentManager related Constants. */
22 public class ConsentConstants {
23 
24     public static final String NOTIFICATION_DISPLAYED_ONCE = "NOTIFICATION-DISPLAYED-ONCE";
25 
26     public static final String GA_UX_NOTIFICATION_DISPLAYED_ONCE =
27             "GA-UX-NOTIFICATION-DISPLAYED-ONCE";
28 
29     public static final String DEFAULT_CONSENT = "DEFAULT_CONSENT";
30 
31     public static final String TOPICS_DEFAULT_CONSENT = "TOPICS_DEFAULT_CONSENT";
32 
33     public static final String FLEDGE_DEFAULT_CONSENT = "FLEDGE_DEFAULT_CONSENT";
34 
35     public static final String MEASUREMENT_DEFAULT_CONSENT = "MEASUREMENT_DEFAULT_CONSENT";
36 
37     public static final String DEFAULT_AD_ID_STATE = "DEFAULT_AD_ID_STATE";
38 
39     public static final String MANUAL_INTERACTION_WITH_CONSENT_RECORDED =
40             "MANUAL_INTERACTION_WITH_CONSENT_RECORDED";
41 
42     public static final String CONSENT_KEY = "CONSENT";
43 
44     // When persisting data to AppSearch, the key cannot be a proper subset of other keys since
45     // Search does not support full match.
46     public static final String CONSENT_KEY_FOR_ALL = "CONSENT-ALL";
47 
48     // Internal datastore version
49     static final int STORAGE_VERSION = 1;
50 
51     // Internal datastore filename. The name should be unique to avoid multiple threads or
52     // processes to update the same file.
53     static final String STORAGE_XML_IDENTIFIER =
54             FileCompatUtils.getAdservicesFilename("ConsentManagerStorageIdentifier.xml");
55 
56     // The name of shared preferences file to store status of one-time migrations.
57     // Once a migration has happened, it marks corresponding shared preferences to prevent it
58     // happens again.
59     static final String SHARED_PREFS_CONSENT = "PPAPI_Consent";
60 
61     public static final String SHARED_PREFS_KEY_HAS_MIGRATED_TO_APP_SEARCH =
62             "CONSENT_HAS_MIGRATED_TO_APP_SEARCH";
63 
64     // Shared preferences to mark whether consent data from AppSearch has migrated to AdServices.
65     public static final String SHARED_PREFS_KEY_APPSEARCH_HAS_MIGRATED =
66             "CONSENT_HAS_MIGRATED_FROM_APPSEARCH";
67 
68     // Shared preferences to mark whether PPAPI consent has been migrated to system server
69     public static final String SHARED_PREFS_KEY_HAS_MIGRATED =
70             "CONSENT_HAS_MIGRATED_TO_SYSTEM_SERVER";
71 
72     // Shared preferences to mark whether AdExtData has been migrated to system server
73     public static final String SHARED_PREFS_KEY_MIGRATED_FROM_ADEXTDATA_TO_SYSTEM_SERVER =
74             "CONSENT_HAS_MIGRATED_FROM_ADEXTDATA_TO_SYSTEM_SERVER";
75 
76     // Shared preferences to mark whether PPAPI consent has been cleared.
77     static final String SHARED_PREFS_KEY_PPAPI_HAS_CLEARED = "CONSENT_HAS_CLEARED_IN_PPAPI";
78 
79     static final String ERROR_MESSAGE_WHILE_GET_CONTENT =
80             "getConsent method failed. Revoked consent is returned as fallback.";
81 
82     static final String ERROR_MESSAGE_WHILE_SET_CONTENT = "setConsent method failed.";
83 
84     static final String ERROR_MESSAGE_INVALID_CONSENT_SOURCE_OF_TRUTH =
85             "Invalid type of consent source of truth.";
86 
87     public static final String ERROR_MESSAGE_INVALID_BLOCKED_TOPICS_SOURCE_OF_TRUTH =
88             "Invalid type of blocked topics source of truth.";
89 
90     public static final String ERROR_MESSAGE_APPSEARCH_FAILURE =
91             "Failed to persist data to AppSearch.";
92 
93     public static final String IS_AD_ID_ENABLED = "IS_AD_ID_ENABLED";
94 
95     public static final String IS_U18_ACCOUNT = "IS_U18_ACCOUNT";
96 
97     public static final String IS_ENTRY_POINT_ENABLED = "IS_ENTRY_POINT_ENABLED";
98 
99     public static final String IS_ADULT_ACCOUNT = "IS_ADULT_ACCOUNT";
100 
101     public static final String WAS_U18_NOTIFICATION_DISPLAYED = "WAS_U18_NOTIFICATION_DISPLAYED";
102 
103     public static final String PAS_NOTIFICATION_DISPLAYED_ONCE = "PAS_NOTIFICATION_DISPLAYED_ONCE";
104 
105     public static final String PAS_NOTIFICATION_OPENED = "PAS_NOTIFICATION_OPENED";
106 
107     public static final String IS_MEASUREMENT_DATA_RESET = "IS_MEASUREMENT_DATA_RESET";
108 
109     public static final String IS_PA_DATA_RESET = "IS_PA_DATA_RESET";
110 }
111