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 android.app.adservices;
18 
19 import static android.adservices.common.AdServicesPermissions.ACCESS_ADSERVICES_MANAGER;
20 
21 import android.annotation.IntDef;
22 import android.annotation.NonNull;
23 import android.annotation.Nullable;
24 import android.annotation.RequiresPermission;
25 import android.app.adservices.consent.ConsentParcel;
26 import android.app.adservices.topics.TopicParcel;
27 import android.app.sdksandbox.SdkSandboxManager;
28 import android.content.Context;
29 import android.os.Build;
30 import android.os.IBinder;
31 import android.os.RemoteException;
32 
33 import androidx.annotation.RequiresApi;
34 
35 import com.android.internal.annotations.GuardedBy;
36 import com.android.internal.annotations.VisibleForTesting;
37 
38 import java.lang.annotation.Retention;
39 import java.lang.annotation.RetentionPolicy;
40 import java.util.List;
41 import java.util.Objects;
42 
43 /**
44  * AdServices Manager to handle the internal communication between PPAPI process and AdServices
45  * System Service.
46  *
47  * @hide
48  */
49 // TODO(b/269798827): Enable for R.
50 @RequiresApi(Build.VERSION_CODES.S)
51 public final class AdServicesManager {
52 
53     public static final String AD_SERVICES_SYSTEM_SERVICE = "adservices_manager";
54 
55     @GuardedBy("SINGLETON_LOCK")
56     private static AdServicesManager sSingleton;
57 
58     private final IAdServicesManager mService;
59     private static final Object SINGLETON_LOCK = new Object();
60 
61     @IntDef(value = {MEASUREMENT_DELETION})
62     @Retention(RetentionPolicy.SOURCE)
63     public @interface DeletionApiType {}
64 
65     public static final int MEASUREMENT_DELETION = 0;
66 
67     // TODO(b/267789077): Create bit for other APIs.
68 
69     @VisibleForTesting
AdServicesManager(@onNull IAdServicesManager iAdServicesManager)70     public AdServicesManager(@NonNull IAdServicesManager iAdServicesManager) {
71         Objects.requireNonNull(iAdServicesManager, "AdServicesManager is NULL!");
72         mService = iAdServicesManager;
73     }
74 
75     /** Get the singleton of AdServicesManager. Only used on T+ */
76     @Nullable
getInstance(@onNull Context context)77     public static AdServicesManager getInstance(@NonNull Context context) {
78         synchronized (SINGLETON_LOCK) {
79             if (sSingleton == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
80                 // TODO(b/262282035): Fix this work around in U+.
81                 // Get the AdServicesManagerService's Binder from the SdkSandboxManager.
82                 // This is a workaround for b/262282035.
83                 IBinder iBinder =
84                         context.getSystemService(SdkSandboxManager.class).getAdServicesManager();
85                 sSingleton = new AdServicesManager(IAdServicesManager.Stub.asInterface(iBinder));
86             }
87         }
88         return sSingleton;
89     }
90 
91     /** Return the User Consent */
92     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getConsent(@onsentParcel.ConsentApiType int consentApiType)93     public ConsentParcel getConsent(@ConsentParcel.ConsentApiType int consentApiType) {
94         try {
95             return mService.getConsent(consentApiType);
96         } catch (RemoteException e) {
97             throw e.rethrowFromSystemServer();
98         }
99     }
100 
101     /** Set the User Consent */
102     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setConsent(@onNull ConsentParcel consentParcel)103     public void setConsent(@NonNull ConsentParcel consentParcel) {
104         Objects.requireNonNull(consentParcel);
105         try {
106             mService.setConsent(consentParcel);
107         } catch (RemoteException e) {
108             throw e.rethrowFromSystemServer();
109         }
110     }
111 
112     /**
113      * Saves information to the storage that notification was displayed for the first time to the
114      * user.
115      */
116     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordNotificationDisplayed(boolean wasNotificationDisplayed)117     public void recordNotificationDisplayed(boolean wasNotificationDisplayed) {
118         try {
119             mService.recordNotificationDisplayed(wasNotificationDisplayed);
120         } catch (RemoteException e) {
121             throw e.rethrowFromSystemServer();
122         }
123     }
124 
125     /**
126      * Returns information whether Consent Notification was displayed or not.
127      *
128      * @return true if Consent Notification was displayed, otherwise false.
129      */
130     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
wasNotificationDisplayed()131     public boolean wasNotificationDisplayed() {
132         try {
133             return mService.wasNotificationDisplayed();
134         } catch (RemoteException e) {
135             throw e.rethrowFromSystemServer();
136         }
137     }
138 
139     /**
140      * Saves information to the storage that notification was displayed for the first time to the
141      * user.
142      */
143     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordGaUxNotificationDisplayed(boolean wasNotificationDisplayed)144     public void recordGaUxNotificationDisplayed(boolean wasNotificationDisplayed) {
145         try {
146             mService.recordGaUxNotificationDisplayed(wasNotificationDisplayed);
147         } catch (RemoteException e) {
148             throw e.rethrowFromSystemServer();
149         }
150     }
151 
152     /**
153      * Returns information whether user interacted with consent manually.
154      *
155      * @return
156      *     <ul>
157      *       <li>-1 when no manual interaction was recorded
158      *       <li>0 when no data about interaction (similar to null)
159      *       <li>1 when manual interaction was recorded
160      *     </ul>
161      */
162     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getUserManualInteractionWithConsent()163     public int getUserManualInteractionWithConsent() {
164         try {
165             return mService.getUserManualInteractionWithConsent();
166         } catch (RemoteException e) {
167             throw e.rethrowFromSystemServer();
168         }
169     }
170 
171     /** Saves information to the storage that user interacted with consent manually. */
172     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordUserManualInteractionWithConsent(int interaction)173     public void recordUserManualInteractionWithConsent(int interaction) {
174         try {
175             mService.recordUserManualInteractionWithConsent(interaction);
176         } catch (RemoteException e) {
177             throw e.rethrowFromSystemServer();
178         }
179     }
180 
181     /**
182      * Returns information whether Consent GA UX Notification was displayed or not.
183      *
184      * @return true if Consent GA UX Notification was displayed, otherwise false.
185      */
186     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
wasGaUxNotificationDisplayed()187     public boolean wasGaUxNotificationDisplayed() {
188         try {
189             return mService.wasGaUxNotificationDisplayed();
190         } catch (RemoteException e) {
191             throw e.rethrowFromSystemServer();
192         }
193     }
194 
195     /**
196      * Returns information whether Consent PAS Notification was displayed or not.
197      *
198      * @return true if PAS Notification was displayed, otherwise false.
199      */
200     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
wasPasNotificationDisplayed()201     public boolean wasPasNotificationDisplayed() {
202         try {
203             return mService.wasPasNotificationDisplayed();
204         } catch (RemoteException e) {
205             throw e.rethrowFromSystemServer();
206         }
207     }
208 
209     /**
210      * Saves information to the storage that PAS notification was displayed for the first time to
211      * the user.
212      */
213     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordPasNotificationDisplayed(boolean wasNotificationDisplayed)214     public void recordPasNotificationDisplayed(boolean wasNotificationDisplayed) {
215         try {
216             mService.recordPasNotificationDisplayed(wasNotificationDisplayed);
217         } catch (RemoteException e) {
218             throw e.rethrowFromSystemServer();
219         }
220     }
221 
222     /**
223      * Returns information whether Consent PAS Notification was opened or not.
224      *
225      * @return true if PAS Notification was opened, otherwise false.
226      */
227     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
wasPasNotificationOpened()228     public boolean wasPasNotificationOpened() {
229         try {
230             return mService.wasPasNotificationOpened();
231         } catch (RemoteException e) {
232             throw e.rethrowFromSystemServer();
233         }
234     }
235 
236     /** Saves information to the storage that PAS notification was opened. */
237     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordPasNotificationOpened(boolean wasNotificationOpened)238     public void recordPasNotificationOpened(boolean wasNotificationOpened) {
239         try {
240             mService.recordPasNotificationOpened(wasNotificationOpened);
241         } catch (RemoteException e) {
242             throw e.rethrowFromSystemServer();
243         }
244     }
245 
246     /**
247      * Record a blocked topic.
248      *
249      * @param blockedTopicParcels the blocked topic to record
250      */
251     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordBlockedTopic(@onNull List<TopicParcel> blockedTopicParcels)252     public void recordBlockedTopic(@NonNull List<TopicParcel> blockedTopicParcels) {
253         try {
254             mService.recordBlockedTopic(blockedTopicParcels);
255         } catch (RemoteException e) {
256             throw e.rethrowFromSystemServer();
257         }
258     }
259 
260     /**
261      * Remove a blocked topic.
262      *
263      * @param blockedTopicParcel the blocked topic to remove
264      */
265     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
removeBlockedTopic(@onNull TopicParcel blockedTopicParcel)266     public void removeBlockedTopic(@NonNull TopicParcel blockedTopicParcel) {
267         try {
268             mService.removeBlockedTopic(blockedTopicParcel);
269         } catch (RemoteException e) {
270             throw e.rethrowFromSystemServer();
271         }
272     }
273 
274     /**
275      * Get all blocked topics.
276      *
277      * @return a {@code List} of all blocked topics.
278      */
279     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
retrieveAllBlockedTopics()280     public List<TopicParcel> retrieveAllBlockedTopics() {
281         try {
282             return mService.retrieveAllBlockedTopics();
283         } catch (RemoteException e) {
284             throw e.rethrowFromSystemServer();
285         }
286     }
287 
288     /** Clear all Blocked Topics */
289     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
clearAllBlockedTopics()290     public void clearAllBlockedTopics() {
291         try {
292             mService.clearAllBlockedTopics();
293         } catch (RemoteException e) {
294             throw e.rethrowFromSystemServer();
295         }
296     }
297 
298     /** Returns the list of apps with consent. */
299     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getKnownAppsWithConsent(List<String> installedPackages)300     public List<String> getKnownAppsWithConsent(List<String> installedPackages) {
301         try {
302             return mService.getKnownAppsWithConsent(installedPackages);
303         } catch (RemoteException e) {
304             throw e.rethrowFromSystemServer();
305         }
306     }
307 
308     /** Returns the list of apps with revoked consent. */
309     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getAppsWithRevokedConsent(List<String> installedPackages)310     public List<String> getAppsWithRevokedConsent(List<String> installedPackages) {
311         try {
312             return mService.getAppsWithRevokedConsent(installedPackages);
313         } catch (RemoteException e) {
314             throw e.rethrowFromSystemServer();
315         }
316     }
317 
318     /** Set user consent for an app */
319     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setConsentForApp(String packageName, int packageUid, boolean isConsentRevoked)320     public void setConsentForApp(String packageName, int packageUid, boolean isConsentRevoked) {
321         try {
322             mService.setConsentForApp(packageName, packageUid, isConsentRevoked);
323         } catch (RemoteException e) {
324             throw e.rethrowFromSystemServer();
325         }
326     }
327 
328     /** Reset all apps and blocked apps. */
329     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
clearKnownAppsWithConsent()330     public void clearKnownAppsWithConsent() {
331         try {
332             mService.clearKnownAppsWithConsent();
333         } catch (RemoteException e) {
334             throw e.rethrowFromSystemServer();
335         }
336     }
337 
338     /** Reset all apps consent. */
339     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
clearAllAppConsentData()340     public void clearAllAppConsentData() {
341         try {
342             mService.clearAllAppConsentData();
343         } catch (RemoteException e) {
344             throw e.rethrowFromSystemServer();
345         }
346     }
347 
348     /**
349      * Get if user consent is revoked for a given app.
350      *
351      * @return {@code true} if the user consent was revoked.
352      */
353     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isConsentRevokedForApp(String packageName, int packageUid)354     public boolean isConsentRevokedForApp(String packageName, int packageUid) {
355         try {
356             return mService.isConsentRevokedForApp(packageName, packageUid);
357         } catch (RemoteException e) {
358             throw e.rethrowFromSystemServer();
359         }
360     }
361 
362     /**
363      * Set user consent if the app first time request access and/or return consent value for the
364      * app.
365      *
366      * @return {@code true} if user consent was given.
367      */
368     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setConsentForAppIfNew( String packageName, int packageUid, boolean isConsentRevoked)369     public boolean setConsentForAppIfNew(
370             String packageName, int packageUid, boolean isConsentRevoked) {
371         try {
372             return mService.setConsentForAppIfNew(packageName, packageUid, isConsentRevoked);
373         } catch (RemoteException e) {
374             throw e.rethrowFromSystemServer();
375         }
376     }
377 
378     /** Clear the app consent entry for uninstalled app. */
379     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
clearConsentForUninstalledApp(String packageName, int packageUid)380     public void clearConsentForUninstalledApp(String packageName, int packageUid) {
381         try {
382             mService.clearConsentForUninstalledApp(packageName, packageUid);
383         } catch (RemoteException e) {
384             throw e.rethrowFromSystemServer();
385         }
386     }
387 
388     /** Saves information to the storage that a deletion of measurement data occurred. */
389     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordAdServicesDeletionOccurred(@eletionApiType int deletionType)390     public void recordAdServicesDeletionOccurred(@DeletionApiType int deletionType) {
391         try {
392             mService.recordAdServicesDeletionOccurred(deletionType);
393         } catch (RemoteException e) {
394             throw e.rethrowFromSystemServer();
395         }
396     }
397 
398     /** Saves the PP API default consent of a user. */
399     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordDefaultConsent(boolean defaultConsent)400     public void recordDefaultConsent(boolean defaultConsent) {
401         try {
402             mService.recordDefaultConsent(defaultConsent);
403         } catch (RemoteException e) {
404             throw e.rethrowFromSystemServer();
405         }
406     }
407 
408     /** Saves the topics default consent of a user. */
409     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordTopicsDefaultConsent(boolean defaultConsent)410     public void recordTopicsDefaultConsent(boolean defaultConsent) {
411         try {
412             mService.recordTopicsDefaultConsent(defaultConsent);
413         } catch (RemoteException e) {
414             throw e.rethrowFromSystemServer();
415         }
416     }
417 
418     /** Saves the FLEDGE default consent of a user. */
419     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordFledgeDefaultConsent(boolean defaultConsent)420     public void recordFledgeDefaultConsent(boolean defaultConsent) {
421         try {
422             mService.recordFledgeDefaultConsent(defaultConsent);
423         } catch (RemoteException e) {
424             throw e.rethrowFromSystemServer();
425         }
426     }
427 
428     /** Saves the measurement default consent of a user. */
429     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordMeasurementDefaultConsent(boolean defaultConsent)430     public void recordMeasurementDefaultConsent(boolean defaultConsent) {
431         try {
432             mService.recordMeasurementDefaultConsent(defaultConsent);
433         } catch (RemoteException e) {
434             throw e.rethrowFromSystemServer();
435         }
436     }
437 
438     /** Saves the default AdId state of a user. */
439     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
recordDefaultAdIdState(boolean defaultAdIdState)440     public void recordDefaultAdIdState(boolean defaultAdIdState) {
441         try {
442             mService.recordDefaultAdIdState(defaultAdIdState);
443         } catch (RemoteException e) {
444             throw e.rethrowFromSystemServer();
445         }
446     }
447 
448     /**
449      * Checks whether the AdServices module needs to handle data reconciliation after a rollback.
450      */
451     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
needsToHandleRollbackReconciliation(@eletionApiType int deletionType)452     public boolean needsToHandleRollbackReconciliation(@DeletionApiType int deletionType) {
453         try {
454             return mService.needsToHandleRollbackReconciliation(deletionType);
455         } catch (RemoteException e) {
456             throw e.rethrowFromSystemServer();
457         }
458     }
459 
460     /**
461      * Returns the PP API default consent of a user.
462      *
463      * @return true if the PP API default consent is given, false otherwise.
464      */
465     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getDefaultConsent()466     public boolean getDefaultConsent() {
467         try {
468             return mService.getDefaultConsent();
469         } catch (RemoteException e) {
470             throw e.rethrowFromSystemServer();
471         }
472     }
473 
474     /**
475      * Returns the topics default consent of a user.
476      *
477      * @return true if the topics default consent is given, false otherwise.
478      */
479     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getTopicsDefaultConsent()480     public boolean getTopicsDefaultConsent() {
481         try {
482             return mService.getTopicsDefaultConsent();
483         } catch (RemoteException e) {
484             throw e.rethrowFromSystemServer();
485         }
486     }
487 
488     /**
489      * Returns the FLEDGE default consent of a user.
490      *
491      * @return true if the FLEDGE default consent is given, false otherwise.
492      */
493     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getFledgeDefaultConsent()494     public boolean getFledgeDefaultConsent() {
495         try {
496             return mService.getFledgeDefaultConsent();
497         } catch (RemoteException e) {
498             throw e.rethrowFromSystemServer();
499         }
500     }
501 
502     /**
503      * Returns the measurement default consent of a user.
504      *
505      * @return true if the measurement default consent is given, false otherwise.
506      */
507     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getMeasurementDefaultConsent()508     public boolean getMeasurementDefaultConsent() {
509         try {
510             return mService.getMeasurementDefaultConsent();
511         } catch (RemoteException e) {
512             throw e.rethrowFromSystemServer();
513         }
514     }
515 
516     /**
517      * Returns the default AdId state of a user.
518      *
519      * @return true if the default AdId State is enabled, false otherwise.
520      */
521     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getDefaultAdIdState()522     public boolean getDefaultAdIdState() {
523         try {
524             return mService.getDefaultAdIdState();
525         } catch (RemoteException e) {
526             throw e.rethrowFromSystemServer();
527         }
528     }
529 
530     /** Returns the current privacy sandbox feature. */
531     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getCurrentPrivacySandboxFeature()532     public String getCurrentPrivacySandboxFeature() {
533         try {
534             return mService.getCurrentPrivacySandboxFeature();
535         } catch (RemoteException e) {
536             throw e.rethrowFromSystemServer();
537         }
538     }
539 
540     /** Set the current privacy sandbox feature. */
541     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setCurrentPrivacySandboxFeature(String featureType)542     public void setCurrentPrivacySandboxFeature(String featureType) {
543         try {
544             mService.setCurrentPrivacySandboxFeature(featureType);
545         } catch (RemoteException e) {
546             throw e.rethrowFromSystemServer();
547         }
548     }
549 
550     /** Returns whether the isAdIdEnabled bit is true. */
551     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isAdIdEnabled()552     public boolean isAdIdEnabled() {
553         try {
554             return mService.isAdIdEnabled();
555         } catch (RemoteException e) {
556             throw e.rethrowFromSystemServer();
557         }
558     }
559 
560     /** Saves the isAdIdEnabled bit. */
561     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setAdIdEnabled(boolean isAdIdEnabled)562     public void setAdIdEnabled(boolean isAdIdEnabled) {
563         try {
564             mService.setAdIdEnabled(isAdIdEnabled);
565         } catch (RemoteException e) {
566             throw e.rethrowFromSystemServer();
567         }
568     }
569 
570     /** Returns whether the isU18Account bit is true. */
571     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isU18Account()572     public boolean isU18Account() {
573         try {
574             return mService.isU18Account();
575         } catch (RemoteException e) {
576             throw e.rethrowFromSystemServer();
577         }
578     }
579 
580     /** Saves the isU18Account bit. */
581     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setU18Account(boolean isU18Account)582     public void setU18Account(boolean isU18Account) {
583         try {
584             mService.setU18Account(isU18Account);
585         } catch (RemoteException e) {
586             throw e.rethrowFromSystemServer();
587         }
588     }
589 
590     /** Returns whether the isEntryPointEnabled bit is true. */
591     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isEntryPointEnabled()592     public boolean isEntryPointEnabled() {
593         try {
594             return mService.isEntryPointEnabled();
595         } catch (RemoteException e) {
596             throw e.rethrowFromSystemServer();
597         }
598     }
599 
600     /** Saves the isEntryPointEnabled bit. */
601     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setEntryPointEnabled(boolean isEntryPointEnabled)602     public void setEntryPointEnabled(boolean isEntryPointEnabled) {
603         try {
604             mService.setEntryPointEnabled(isEntryPointEnabled);
605         } catch (RemoteException e) {
606             throw e.rethrowFromSystemServer();
607         }
608     }
609 
610     /** Returns whether the isAdultAccount bit is true. */
611     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isAdultAccount()612     public boolean isAdultAccount() {
613         try {
614             return mService.isAdultAccount();
615         } catch (RemoteException e) {
616             throw e.rethrowFromSystemServer();
617         }
618     }
619 
620     /** Saves the isAdultAccount bit. */
621     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setAdultAccount(boolean isAdultAccount)622     public void setAdultAccount(boolean isAdultAccount) {
623         try {
624             mService.setAdultAccount(isAdultAccount);
625         } catch (RemoteException e) {
626             throw e.rethrowFromSystemServer();
627         }
628     }
629 
630     /** Returns whether the wasU18NotificationDisplayed bit is true. */
631     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
wasU18NotificationDisplayed()632     public boolean wasU18NotificationDisplayed() {
633         try {
634             return mService.wasU18NotificationDisplayed();
635         } catch (RemoteException e) {
636             throw e.rethrowFromSystemServer();
637         }
638     }
639 
640     /** Saves the wasU18NotificationDisplayed bit. */
641     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setU18NotificationDisplayed(boolean wasU18NotificationDisplayed)642     public void setU18NotificationDisplayed(boolean wasU18NotificationDisplayed) {
643         try {
644             mService.setU18NotificationDisplayed(wasU18NotificationDisplayed);
645         } catch (RemoteException e) {
646             throw e.rethrowFromSystemServer();
647         }
648     }
649 
650     /** Returns the current UX. */
651     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getUx()652     public String getUx() {
653         try {
654             return mService.getUx();
655         } catch (RemoteException e) {
656             throw e.rethrowFromSystemServer();
657         }
658     }
659 
660     /** Set the current UX. */
661     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setUx(String ux)662     public void setUx(String ux) {
663         try {
664             mService.setUx(ux);
665         } catch (RemoteException e) {
666             throw e.rethrowFromSystemServer();
667         }
668     }
669 
670     /** Returns the current enrollment channel. */
671     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
getEnrollmentChannel()672     public String getEnrollmentChannel() {
673         try {
674             return mService.getEnrollmentChannel();
675         } catch (RemoteException e) {
676             throw e.rethrowFromSystemServer();
677         }
678     }
679 
680     /** Set the current enrollment channel. */
681     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setEnrollmentChannel(String enrollmentChannel)682     public void setEnrollmentChannel(String enrollmentChannel) {
683         try {
684             mService.setEnrollmentChannel(enrollmentChannel);
685         } catch (RemoteException e) {
686             throw e.rethrowFromSystemServer();
687         }
688     }
689 
690     /** Returns whether the isMeasurementDataReset bit is true. */
691     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isMeasurementDataReset()692     public boolean isMeasurementDataReset() {
693         try {
694             return mService.isMeasurementDataReset();
695         } catch (RemoteException e) {
696             throw e.rethrowFromSystemServer();
697         }
698     }
699 
700     /** Saves the isMeasurementDataReset bit. */
701     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setMeasurementDataReset(boolean isMeasurementDataReset)702     public void setMeasurementDataReset(boolean isMeasurementDataReset) {
703         try {
704             mService.setMeasurementDataReset(isMeasurementDataReset);
705         } catch (RemoteException e) {
706             throw e.rethrowFromSystemServer();
707         }
708     }
709 
710     /** Returns whether the isPaDataReset bit is true. */
711     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
isPaDataReset()712     public boolean isPaDataReset() {
713         try {
714             return mService.isPaDataReset();
715         } catch (RemoteException e) {
716             throw e.rethrowFromSystemServer();
717         }
718     }
719 
720     /** Saves the isPaDataReset bit. */
721     @RequiresPermission(ACCESS_ADSERVICES_MANAGER)
setPaDataReset(boolean isPaDataReset)722     public void setPaDataReset(boolean isPaDataReset) {
723         try {
724             mService.setPaDataReset(isPaDataReset);
725         } catch (RemoteException e) {
726             throw e.rethrowFromSystemServer();
727         }
728     }
729 }
730