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.ondevicepersonalization.services.serviceflow; 18 19 import static android.adservices.ondevicepersonalization.Constants.OP_DOWNLOAD; 20 import static android.adservices.ondevicepersonalization.Constants.OP_EXECUTE; 21 import static android.adservices.ondevicepersonalization.Constants.OP_RENDER; 22 import static android.adservices.ondevicepersonalization.Constants.OP_TRAINING_EXAMPLE; 23 import static android.adservices.ondevicepersonalization.Constants.OP_WEB_TRIGGER; 24 import static android.adservices.ondevicepersonalization.Constants.OP_WEB_VIEW_EVENT; 25 26 import static com.android.ondevicepersonalization.services.PhFlags.KEY_APP_REQUEST_FLOW_DEADLINE_SECONDS; 27 import static com.android.ondevicepersonalization.services.PhFlags.KEY_DOWNLOAD_FLOW_DEADLINE_SECONDS; 28 import static com.android.ondevicepersonalization.services.PhFlags.KEY_EXAMPLE_STORE_FLOW_DEADLINE_SECONDS; 29 import static com.android.ondevicepersonalization.services.PhFlags.KEY_RENDER_FLOW_DEADLINE_SECONDS; 30 import static com.android.ondevicepersonalization.services.PhFlags.KEY_WEB_TRIGGER_FLOW_DEADLINE_SECONDS; 31 import static com.android.ondevicepersonalization.services.PhFlags.KEY_WEB_VIEW_FLOW_DEADLINE_SECONDS; 32 33 import com.android.ondevicepersonalization.services.FlagsFactory; 34 35 /** Collection of on-device personalization service flows. */ 36 public enum ServiceFlowType { 37 38 APP_REQUEST_FLOW( 39 "AppRequest", OP_EXECUTE, Priority.HIGH, 40 (int) FlagsFactory.getFlags().getStableFlag(KEY_APP_REQUEST_FLOW_DEADLINE_SECONDS)), 41 42 RENDER_FLOW( 43 "Render", OP_RENDER, Priority.HIGH, 44 (int) FlagsFactory.getFlags().getStableFlag(KEY_RENDER_FLOW_DEADLINE_SECONDS)), 45 46 WEB_TRIGGER_FLOW( 47 "WebTrigger", OP_WEB_TRIGGER, Priority.NORMAL, 48 (int) FlagsFactory.getFlags().getStableFlag(KEY_WEB_TRIGGER_FLOW_DEADLINE_SECONDS)), 49 50 WEB_VIEW_FLOW( 51 "ComputeEventMetrics", OP_WEB_VIEW_EVENT, Priority.NORMAL, 52 (int) FlagsFactory.getFlags().getStableFlag(KEY_WEB_VIEW_FLOW_DEADLINE_SECONDS)), 53 54 EXAMPLE_STORE_FLOW( 55 "ExampleStore", OP_TRAINING_EXAMPLE, Priority.NORMAL, 56 (int) FlagsFactory.getFlags().getStableFlag(KEY_EXAMPLE_STORE_FLOW_DEADLINE_SECONDS)), 57 58 DOWNLOAD_FLOW( 59 "DownloadJob", OP_DOWNLOAD, Priority.LOW, 60 (int) FlagsFactory.getFlags().getStableFlag(KEY_DOWNLOAD_FLOW_DEADLINE_SECONDS)); 61 62 final String mTaskName; 63 final int mOperationCode; 64 final Priority mPriority; 65 final int mExecutionTimeout; 66 ServiceFlowType(String taskName, int operationCode, Priority priority, int executionTimeout)67 ServiceFlowType(String taskName, int operationCode, Priority priority, int executionTimeout) { 68 mTaskName = taskName; 69 mOperationCode = operationCode; 70 mPriority = priority; 71 mExecutionTimeout = executionTimeout; 72 } 73 getTaskName()74 public String getTaskName() { 75 return mTaskName; 76 } 77 getOperationCode()78 public int getOperationCode() { 79 return mOperationCode; 80 } 81 getPriority()82 public Priority getPriority() { 83 return mPriority; 84 } 85 getExecutionTimeout()86 public int getExecutionTimeout() { 87 return mExecutionTimeout; 88 } 89 90 public enum Priority { 91 HIGH, 92 NORMAL, 93 LOW 94 } 95 } 96