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.devapi; 18 19 import android.annotation.Nullable; 20 21 import com.google.auto.value.AutoValue; 22 23 /** 24 * Instances of this class are used to hold information required by the developer features supported 25 * by the AdSelection and CustomAudience API. An instance of this class is created while serving 26 * each client call and will be used by underlying services to understand if they need to activate 27 * development features and to provide information useful for those features. 28 */ 29 @AutoValue 30 public abstract class DevContext { 31 /** 32 * @return true if the developer options are enabled for this service call. 33 */ getDevOptionsEnabled()34 public abstract boolean getDevOptionsEnabled(); 35 36 /** 37 * @return The package name for the calling app or NULL if the dev options are not enabled. 38 */ 39 @Nullable getCallingAppPackageName()40 public abstract String getCallingAppPackageName(); 41 42 /** 43 * @return Generic builder 44 */ builder()45 public static DevContext.Builder builder() { 46 return new AutoValue_DevContext.Builder(); 47 } 48 49 /** 50 * @return An instance of {@link DevContext} with developer options disabled. 51 */ createForDevOptionsDisabled()52 public static DevContext createForDevOptionsDisabled() { 53 return DevContext.builder().setDevOptionsEnabled(false).build(); 54 } 55 56 /** The Builder for {@link DevContext} */ 57 @AutoValue.Builder 58 public abstract static class Builder { 59 /** Sets the value for the dev options enabled flag */ setDevOptionsEnabled(boolean flag)60 public abstract DevContext.Builder setDevOptionsEnabled(boolean flag); 61 62 /** Sets the value for the calling app package */ setCallingAppPackageName(@ullable String value)63 public abstract DevContext.Builder setCallingAppPackageName(@Nullable String value); 64 65 /** Build an AdBiddingOutcome object. */ build()66 public abstract DevContext build(); 67 } 68 } 69