xref: /aosp_15_r20/external/android_onboarding/java/com/android/onboarding/tasks/OnboardingTaskState.kt (revision c625018464ae97c56936c82b1b617e11aa899faa)
1 package com.android.onboarding.tasks
2 
3 /**
4  * Represents the state of an onboarding task.
5  *
6  * @param Result The type of the result associated with the task.
7  */
8 sealed class OnboardingTaskState<Result> {
9 
10   /**
11    * Represents the in-progress state of an onboarding task.
12    *
13    * @param result The current result, if available.
14    */
15   data class InProgress<Result>(var result: Result? = null) : OnboardingTaskState<Result>()
16 
17   /**
18    * Represents the completed state of an onboarding task.
19    *
20    * @param result The result of the completed task.
21    */
22   data class Completed<Result>(val result: Result? = null) : OnboardingTaskState<Result>()
23 
24   /**
25    * Represents the failed state of an onboarding task.
26    *
27    * @param errorMessage The error message describing the failure.
28    * @param result The result associated with the failed task, if available.
29    */
30   data class Failed<Result>(val errorMessage: String, val result: Result? = null) :
31     OnboardingTaskState<Result>()
32 }
33 
34 const val ERROR_INSTANTIATING_TASK = "Error instantiating task."
35 const val ERROR_TASK_CANT_BE_FOUND = "Task can't be found."
36 const val ERROR_RUNNING_TASK = "Task execution failed with an exception."
37 const val ERROR_FAILED_BIND_TASK_SERVICE = "Failed to bind to the task service."
38