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 package com.android.adservices.shared.spe.logging;
17 
18 import com.google.auto.value.AutoValue;
19 
20 /**
21  * Class for AdServicesBackgroundJobsExecutionReportedStats atom. It's used by {@link
22  * JobServiceLogger}.
23  */
24 @AutoValue
25 public abstract class ExecutionReportedStats {
26     /** @return the unique id of a background job. */
getJobId()27     public abstract int getJobId();
28 
29     /**
30      * @return Time interval from the start to the end of an execution of a background job. It is on
31      *     a millisecond basis.
32      */
getExecutionLatencyMs()33     public abstract int getExecutionLatencyMs();
34 
35     /**
36      * @return Time interval from the start of previous execution to the start of current execution
37      *     of a background job. It is on a minute basis.
38      */
getExecutionPeriodMinute()39     public abstract int getExecutionPeriodMinute();
40 
41     /** @return Type of the result code that implies different execution results. */
getExecutionResultCode()42     public abstract int getExecutionResultCode();
43 
44     /**
45      * @return The returned reason onStopJob() was called. This is only applicable when the state is
46      *     FINISHED, but may be undefined if JobService.onStopJob() was never called for the job.
47      *     The default value is STOP_REASON_UNDEFINED.
48      */
getStopReason()49     public abstract int getStopReason();
50 
51     /**
52      * @return The module name for which the job run is being reported.
53      */
getModuleName()54     public abstract int getModuleName();
55 
56     /** Create an instance for {@link ExecutionReportedStats.Builder}. */
builder()57     public static ExecutionReportedStats.Builder builder() {
58         return new AutoValue_ExecutionReportedStats.Builder();
59     }
60 
61     /** Builder class for {@link ExecutionReportedStats} */
62     @AutoValue.Builder
63     public abstract static class Builder {
64         /** Set Job ID. */
setJobId(int value)65         public abstract Builder setJobId(int value);
66 
67         /** Set job execution latency in millisecond. */
setExecutionLatencyMs(int value)68         public abstract Builder setExecutionLatencyMs(int value);
69 
70         /** Set job period in minute. */
setExecutionPeriodMinute(int value)71         public abstract Builder setExecutionPeriodMinute(int value);
72 
73         /** Set job execution result code. */
setExecutionResultCode(int value)74         public abstract Builder setExecutionResultCode(int value);
75 
76         /** Set job stop reason. */
setStopReason(int value)77         public abstract Builder setStopReason(int value);
78 
79         /** Set module name. */
setModuleName(int value)80         public abstract Builder setModuleName(int value);
81 
82         /** Build an instance of {@link ExecutionReportedStats}. */
build()83         public abstract ExecutionReportedStats build();
84     }
85 }
86