• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package com.android.adservices.service.ui.ux.impl;
17 
18 import static com.android.adservices.service.FlagsConstants.KEY_GA_UX_FEATURE_ENABLED;
19 
20 import android.content.Context;
21 import android.os.Build;
22 
23 import androidx.annotation.RequiresApi;
24 
25 import com.android.adservices.service.consent.ConsentManager;
26 import com.android.adservices.service.ui.data.UxStatesManager;
27 import com.android.adservices.service.ui.enrollment.base.PrivacySandboxEnrollmentChannel;
28 import com.android.adservices.service.ui.ux.base.PrivacySandboxUx;
29 
30 import com.google.errorprone.annotations.Immutable;
31 
32 /** The privacy sandbox (general availability) GA UX. */
33 @RequiresApi(Build.VERSION_CODES.S)
34 @Immutable
35 public class GaUx implements PrivacySandboxUx {
36 
37     /** Whether a user is eligible for the privacy sandbox GA UX. */
isEligible(ConsentManager consentManager, UxStatesManager uxStatesManager)38     public boolean isEligible(ConsentManager consentManager, UxStatesManager uxStatesManager) {
39         return uxStatesManager.getFlag(KEY_GA_UX_FEATURE_ENABLED)
40                 && consentManager.isAdultAccount();
41     }
42 
43     /** Enroll user through one of the available GA UX enrollment channels if needed. */
handleEnrollment( PrivacySandboxEnrollmentChannel enrollmentChannel, Context context, ConsentManager consentManager)44     public void handleEnrollment(
45             PrivacySandboxEnrollmentChannel enrollmentChannel,
46             Context context,
47             ConsentManager consentManager) {
48         enrollmentChannel.enroll(context, consentManager);
49     }
50 }
51