• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.adservices.service.measurement.util;
18 
19 import androidx.annotation.Nullable;
20 
21 import com.android.adservices.service.measurement.EventSurfaceType;
22 import com.android.adservices.service.measurement.Source;
23 import com.android.adservices.service.measurement.Trigger;
24 
25 /** Debug-related utilities for measurement. */
26 public final class Debug {
Debug()27     private Debug() { }
28 
29     /**
30      * Utility method to determine attribution debug report permission.
31      *
32      * @param source the {@code Source}
33      * @param trigger the {@code Trigger}
34      * @param sourceDebugKey the source debug key
35      * @param triggerDebugKey the trigger debug key
36      * @return whether the parameter configuration permits an attribution debug report
37      */
isAttributionDebugReportPermitted(Source source, Trigger trigger, @Nullable UnsignedLong sourceDebugKey, @Nullable UnsignedLong triggerDebugKey)38     public static boolean isAttributionDebugReportPermitted(Source source, Trigger trigger,
39             @Nullable UnsignedLong sourceDebugKey, @Nullable UnsignedLong triggerDebugKey) {
40         if (source.getPublisherType() == EventSurfaceType.WEB
41                 && trigger.getDestinationType() == EventSurfaceType.WEB) {
42             return sourceDebugKey != null && triggerDebugKey != null;
43         } else {
44             return sourceDebugKey != null || triggerDebugKey != null;
45         }
46     }
47 
48 }
49