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.ondevicepersonalization.services;
18 
19 import com.android.adservices.shared.common.flags.ConfigFlag;
20 import com.android.adservices.shared.common.flags.FeatureFlag;
21 import com.android.adservices.shared.common.flags.ModuleSharedFlags;
22 
23 /**
24  * OnDevicePersonalization Feature Flags interface. This Flags interface hold the default values
25  * of flags. The default values in this class must match with the default values in PH since we
26  * will migrate to Flag Codegen in the future. With that migration, the Flags.java file will be
27  * generated from the GCL.
28  */
29 public interface Flags extends ModuleSharedFlags {
30     /**
31      * Global OnDevicePersonalization Kill Switch. This overrides all other killswitches.
32      * The default value is true which means OnDevicePersonalization is disabled.
33      * This flag is used for ramp-up and emergency turning off the whole module.
34      */
35     boolean GLOBAL_KILL_SWITCH = true;
36 
37     /**
38      * P/H flag to override the personalization status for end-to-end tests.
39      * The default value is false, which means UserPrivacyStatus#personalizationStatus is not
40      * override by PERSONALIZATION_STATUS_OVERRIDE_VALUE. If true, returns the personalization
41      * status in PERSONALIZATION_STATUS_OVERRIDE_VALUE.
42      */
43     boolean ENABLE_PERSONALIZATION_STATUS_OVERRIDE = false;
44 
45     /**
46      * Value of the personalization status, if ENABLE_PERSONALIZATION_STATUS_OVERRIDE is true.
47      */
48     boolean PERSONALIZATION_STATUS_OVERRIDE_VALUE = false;
49 
50     /**
51      * Deadline for calls from ODP to isolated services.
52      */
53     int ISOLATED_SERVICE_DEADLINE_SECONDS = 30;
54 
55     /**
56      * Execution deadline for app request flow.
57      */
58     int APP_REQUEST_FLOW_DEADLINE_SECONDS = 30;
59 
60     /**
61      * Executiton deadline for render flow.
62      */
63     int RENDER_FLOW_DEADLINE_SECONDS = 30;
64 
65     /**
66      * Executiton deadline for web view flow.
67      */
68     int WEB_VIEW_FLOW_DEADLINE_SECONDS = 30;
69 
70     /**
71      * Executiton deadline for web trigger flow.
72      */
73     int WEB_TRIGGER_FLOW_DEADLINE_SECONDS = 30;
74 
75     /** Default value for the list of trusted partner app names. */
76     String DEFAULT_TRUSTED_PARTNER_APPS_LIST = "";
77 
78     /** Default value for the shared isolated process feature. */
79     boolean DEFAULT_SHARED_ISOLATED_PROCESS_FEATURE_ENABLED = true;
80 
81     /** Default value for enabling client error logging. */
82     boolean DEFAULT_CLIENT_ERROR_LOGGING_ENABLED = false;
83 
84     /** Default value for the base64 encoded Job Policy proto for ODP background jobs. */
85     @ConfigFlag String DEFAULT_ODP_MODULE_JOB_POLICY = "";
86 
87     /** Default value for SPE to be enabled for the pilot background jobs. */
88     @FeatureFlag boolean DEFAULT_SPE_PILOT_JOB_ENABLED = false;
89 
90     /** Default value for isolated service debugging flag. */
91     boolean DEFAULT_ISOLATED_SERVICE_DEBUGGING_ENABLED = false;
92 
93     /** Default delay before starting a data reset. */
94     int DEFAULT_RESET_DATA_DELAY_SECONDS = 24 * 60 * 60; // 24 hours
95 
96     /** Default deadline for data reset. */
97     int DEFAULT_RESET_DATA_DEADLINE_SECONDS = 30 * 60 * 60; // 30 hours
98 
99     String DEFAULT_CALLER_APP_ALLOW_LIST =
100             "android.ondevicepersonalization,"
101                     + "android.ondevicepersonalization.test.scenario,"
102                     + "com.android.federatedcompute.services,"
103                     + "com.android.libraries.pcc.chronicle.test,"
104                     + "com.android.ondevicepersonalization,"
105                     + "com.android.ondevicepersonalization.cts.e2e,"
106                     + "com.android.ondevicepersonalization.federatedcomputetests,"
107                     + "com.android.ondevicepersonalization.libraries.plugin,"
108                     + "com.android.ondevicepersonalization.manualtests,"
109                     + "com.android.ondevicepersonalization.plugintests,"
110                     + "com.android.ondevicepersonalization.services,"
111                     + "com.android.ondevicepersonalization.servicetests,"
112                     + "com.android.ondevicepersonalization.systemserviceapitests,"
113                     + "com.android.ondevicepersonalization.systemserviceimpltests,"
114                     + "com.android.ondevicepersonalization.testing.sampleservice,"
115                     + "com.example.odpclient,"
116                     + "com.example.odpsamplenetwork,"
117                     + "com.example.odptargetingapp1,"
118                     + "com.example.odptargetingapp2";
119 
120     String DEFAULT_ISOLATED_SERVICE_ALLOW_LIST =
121             "android.ondevicepersonalization,"
122                     + "android.ondevicepersonalization.test.scenario,"
123                     + "com.android.federatedcompute.services,"
124                     + "com.android.libraries.pcc.chronicle.test,"
125                     + "com.android.ondevicepersonalization,"
126                     + "com.android.ondevicepersonalization.cts.e2e,"
127                     + "com.android.ondevicepersonalization.federatedcomputetests,"
128                     + "com.android.ondevicepersonalization.libraries.plugin,"
129                     + "com.android.ondevicepersonalization.manualtests,"
130                     + "com.android.ondevicepersonalization.plugintests,"
131                     + "com.android.ondevicepersonalization.services,"
132                     + "com.android.ondevicepersonalization.servicetests,"
133                     + "com.android.ondevicepersonalization.systemserviceapitests,"
134                     + "com.android.ondevicepersonalization.systemserviceimpltests,"
135                     + "com.android.ondevicepersonalization.testing.sampleservice,"
136                     + "com.example.odpclient,"
137                     + "com.example.odpsamplenetwork,"
138                     + "com.example.odptargetingapp1,"
139                     + "com.example.odptargetingapp2";
140 
141     String DEFAULT_OUTPUT_DATA_ALLOW_LIST = "";
142 
143     /**
144      * Default value of valid duration of user control cache in milliseconds (24 hours).
145      */
146     long USER_CONTROL_CACHE_IN_MILLIS = 86400000;
147 
getGlobalKillSwitch()148     default boolean getGlobalKillSwitch() {
149         return GLOBAL_KILL_SWITCH;
150     }
151 
isPersonalizationStatusOverrideEnabled()152     default boolean isPersonalizationStatusOverrideEnabled() {
153         return ENABLE_PERSONALIZATION_STATUS_OVERRIDE;
154     }
155 
getPersonalizationStatusOverrideValue()156     default boolean getPersonalizationStatusOverrideValue() {
157         return PERSONALIZATION_STATUS_OVERRIDE_VALUE;
158     }
159 
getIsolatedServiceDeadlineSeconds()160     default int getIsolatedServiceDeadlineSeconds() {
161         return ISOLATED_SERVICE_DEADLINE_SECONDS;
162     }
163 
getAppRequestFlowDeadlineSeconds()164     default int getAppRequestFlowDeadlineSeconds() {
165         return APP_REQUEST_FLOW_DEADLINE_SECONDS;
166     }
167 
getRenderFlowDeadlineSeconds()168     default int getRenderFlowDeadlineSeconds() {
169         return RENDER_FLOW_DEADLINE_SECONDS;
170     }
171 
getWebViewFlowDeadlineSeconds()172     default int getWebViewFlowDeadlineSeconds() {
173         return WEB_VIEW_FLOW_DEADLINE_SECONDS;
174     }
175 
getWebTriggerFlowDeadlineSeconds()176     default int getWebTriggerFlowDeadlineSeconds() {
177         return WEB_TRIGGER_FLOW_DEADLINE_SECONDS;
178     }
179 
180     /**
181      * Executiton deadline for example store flow.
182      */
183     int EXAMPLE_STORE_FLOW_DEADLINE_SECONDS = 30;
184 
getExampleStoreFlowDeadlineSeconds()185     default int getExampleStoreFlowDeadlineSeconds() {
186         return EXAMPLE_STORE_FLOW_DEADLINE_SECONDS;
187     }
188 
189     /**
190      * Executiton deadline for download flow.
191      */
192     int DOWNLOAD_FLOW_DEADLINE_SECONDS = 30;
193 
getDownloadFlowDeadlineSeconds()194     default int getDownloadFlowDeadlineSeconds() {
195         return DOWNLOAD_FLOW_DEADLINE_SECONDS;
196     }
197 
getTrustedPartnerAppsList()198     default String getTrustedPartnerAppsList() {
199         return DEFAULT_TRUSTED_PARTNER_APPS_LIST;
200     }
201 
isSharedIsolatedProcessFeatureEnabled()202     default boolean isSharedIsolatedProcessFeatureEnabled() {
203         return DEFAULT_SHARED_ISOLATED_PROCESS_FEATURE_ENABLED;
204     }
205 
206     /**
207      * The ART image loading optimization is disabled by default.
208      */
209     boolean IS_ART_IMAGE_LOADING_OPTIMIZATION_ENABLED = false;
210 
isArtImageLoadingOptimizationEnabled()211     default boolean isArtImageLoadingOptimizationEnabled() {
212         return IS_ART_IMAGE_LOADING_OPTIMIZATION_ENABLED;
213     }
214 
getCallerAppAllowList()215     default String getCallerAppAllowList() {
216         return DEFAULT_CALLER_APP_ALLOW_LIST;
217     }
218 
getIsolatedServiceAllowList()219     default String getIsolatedServiceAllowList() {
220         return DEFAULT_ISOLATED_SERVICE_ALLOW_LIST;
221     }
222 
getUserControlCacheInMillis()223     default long getUserControlCacheInMillis() {
224         return USER_CONTROL_CACHE_IN_MILLIS;
225     }
226 
getOutputDataAllowList()227     default String getOutputDataAllowList() {
228         return DEFAULT_OUTPUT_DATA_ALLOW_LIST;
229     }
230 
isIsolatedServiceDebuggingEnabled()231     default boolean isIsolatedServiceDebuggingEnabled() {
232         return DEFAULT_ISOLATED_SERVICE_DEBUGGING_ENABLED;
233     }
234 
getOdpModuleJobPolicy()235     default String getOdpModuleJobPolicy() {
236         return DEFAULT_ODP_MODULE_JOB_POLICY;
237     }
238 
getSpePilotJobEnabled()239     default boolean getSpePilotJobEnabled() {
240         return DEFAULT_SPE_PILOT_JOB_ENABLED;
241     }
242 
243     /** Set all stable flags. */
setStableFlags()244     default void setStableFlags() {}
245 
246     /** Get a stable flag based on the flag name. */
getStableFlag(String flagName)247     default Object getStableFlag(String flagName) {
248         return null;
249     }
250 
getEnableClientErrorLogging()251     default boolean getEnableClientErrorLogging() {
252         return DEFAULT_CLIENT_ERROR_LOGGING_ENABLED;
253     }
254 
getResetDataDelaySeconds()255     default int getResetDataDelaySeconds() {
256         return DEFAULT_RESET_DATA_DELAY_SECONDS;
257     }
258 
getResetDataDeadlineSeconds()259     default int getResetDataDeadlineSeconds() {
260         return DEFAULT_RESET_DATA_DEADLINE_SECONDS;
261     }
262 
263     // Keep app install in last 30 days.
264     long DEFAULT_APP_INSTALL_HISTORY_TTL_MILLIS = 30 * 24 * 60 * 60 * 1000L;
265 
getAppInstallHistoryTtlInMillis()266     default long getAppInstallHistoryTtlInMillis() {
267         return DEFAULT_APP_INSTALL_HISTORY_TTL_MILLIS;
268     }
269 }
270