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; 18 19 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.TOPICS_EPOCH_JOB_BATTERY_CONSTRAINT_UNKNOWN_SETTING; 20 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.TOPICS_RESCHEDULE_EPOCH_JOB_STATUS_UNSET; 21 22 import com.google.auto.value.AutoValue; 23 24 /** Class for logging topics epoch job setting during scheduling EpochJobService. */ 25 @AutoValue 26 public abstract class TopicsScheduleEpochJobSettingReportedStats { 27 /** Returns the status when forcing reschedule EpochJob. */ 28 @AdsRelevanceStatusUtils.TopicsRescheduleEpochJobStatus getRescheduleEpochJobStatus()29 public abstract int getRescheduleEpochJobStatus(); 30 31 /** Returns the previous epoch job setting. This field will be UNKNOWN_SETTING 32 * when reschedule EpochJob status is not RESCHEDULE_SUCCESS. */ 33 @AdsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint getPreviousEpochJobSetting()34 public abstract int getPreviousEpochJobSetting(); 35 36 /** Returns the current epoch job setting. This field will be UNKNOWN_SETTING 37 * when reschedule EpochJob status is not RESCHEDULE_SUCCESS. */ 38 @AdsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint getCurrentEpochJobSetting()39 public abstract int getCurrentEpochJobSetting(); 40 41 /** Returns the epoch job setting when scheduling the epoch job in 42 * {@code EpochJobService.scheduleIfNeeded()} */ 43 @AdsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint getScheduleIfNeededEpochJobStatus()44 public abstract int getScheduleIfNeededEpochJobStatus(); 45 46 /** Returns generic builder. */ builder()47 public static Builder builder() { 48 return new AutoValue_TopicsScheduleEpochJobSettingReportedStats.Builder() 49 .setRescheduleEpochJobStatus(TOPICS_RESCHEDULE_EPOCH_JOB_STATUS_UNSET) 50 .setPreviousEpochJobSetting(TOPICS_EPOCH_JOB_BATTERY_CONSTRAINT_UNKNOWN_SETTING) 51 .setCurrentEpochJobSetting(TOPICS_EPOCH_JOB_BATTERY_CONSTRAINT_UNKNOWN_SETTING) 52 .setScheduleIfNeededEpochJobStatus( 53 TOPICS_EPOCH_JOB_BATTERY_CONSTRAINT_UNKNOWN_SETTING); 54 } 55 56 /** Builder class for TopicsScheduleEpochJobSettingReportedStats. */ 57 @AutoValue.Builder 58 public abstract static class Builder { setRescheduleEpochJobStatus( @dsRelevanceStatusUtils.TopicsRescheduleEpochJobStatus int value)59 public abstract Builder setRescheduleEpochJobStatus( 60 @AdsRelevanceStatusUtils.TopicsRescheduleEpochJobStatus int value); 61 setPreviousEpochJobSetting( @dsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint int value)62 public abstract Builder setPreviousEpochJobSetting( 63 @AdsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint int value); 64 setCurrentEpochJobSetting( @dsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint int value)65 public abstract Builder setCurrentEpochJobSetting( 66 @AdsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint int value); 67 setScheduleIfNeededEpochJobStatus( @dsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint int value)68 public abstract Builder setScheduleIfNeededEpochJobStatus( 69 @AdsRelevanceStatusUtils.TopicsEpochJobBatteryConstraint int value); 70 build()71 public abstract TopicsScheduleEpochJobSettingReportedStats build(); 72 } 73 } 74