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