1 /* 2 * Copyright (C) 2024 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.stats.kanon; 18 19 import android.annotation.Nullable; 20 21 import com.google.auto.value.AutoValue; 22 23 @AutoValue 24 public abstract class KAnonBackgroundJobStatusStats { 25 /** Result of the KAnon background job. */ getKAnonJobResult()26 public abstract int getKAnonJobResult(); 27 28 /** Number of messages that were attempted to be signed/joined in this background run. */ getTotalMessagesAttempted()29 public abstract int getTotalMessagesAttempted(); 30 31 /** Number of messages that are left in the database yet to be signed/joined. */ getMessagesInDBLeft()32 public abstract int getMessagesInDBLeft(); 33 34 /** Number of failed messages during the sign process in this background run. */ 35 @Nullable getMessagesFailedToSign()36 public abstract Integer getMessagesFailedToSign(); 37 38 /** Number of failed messages during the join process in this background run. */ 39 @Nullable getMessagesFailedToJoin()40 public abstract Integer getMessagesFailedToJoin(); 41 42 /** Latency for this KAnon background run. */ getLatencyInMs()43 public abstract int getLatencyInMs(); 44 45 /** Returns a {@link Builder} for {@link KAnonBackgroundJobStatusStats} */ builder()46 public static Builder builder() { 47 return new AutoValue_KAnonBackgroundJobStatusStats.Builder() 48 .setKAnonJobResult(0) 49 .setLatencyInMs(0) 50 .setMessagesFailedToJoin(0) 51 .setMessagesFailedToSign(0); 52 } 53 54 @AutoValue.Builder 55 public abstract static class Builder { 56 /** Sets the kanonJobResult field */ setKAnonJobResult(int jobResult)57 public abstract Builder setKAnonJobResult(int jobResult); 58 59 /** Sets the totalMessagesAttempted field. */ setTotalMessagesAttempted(int totalMessagesAttempted)60 public abstract Builder setTotalMessagesAttempted(int totalMessagesAttempted); 61 62 /** Sets the number of messages left in the database. */ setMessagesInDBLeft(int messagesInDBLeft)63 public abstract Builder setMessagesInDBLeft(int messagesInDBLeft); 64 65 /** Sets the number of messages failed in the sign process. */ setMessagesFailedToSign(@ullable Integer messagesFailedToSign)66 public abstract Builder setMessagesFailedToSign(@Nullable Integer messagesFailedToSign); 67 68 /** Sets the number of messages failed in the join process. */ setMessagesFailedToJoin(@ullable Integer messagesFailedToJoin)69 public abstract Builder setMessagesFailedToJoin(@Nullable Integer messagesFailedToJoin); 70 71 /** Sets the latency of the background job. */ setLatencyInMs(int latencyInMs)72 public abstract Builder setLatencyInMs(int latencyInMs); 73 74 /** Builds and returns a {@link KAnonBackgroundJobStatusStats} object. */ build()75 public abstract KAnonBackgroundJobStatusStats build(); 76 } 77 } 78