• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.onboarding.tasks
2 
3 import android.os.Parcel
4 import android.os.Parcelable
5 
6 /**
7  * Represents a token to an onboarding task executor along with its associated contract.
8  *
9  * This class is used to uniquely identify and reference an onboarding task executor and its
10  * contract.
11  *
12  * @property taskContractClass The fully qualified class name of the associated
13  *   [OnboardingTaskContract].
14  * @property taskComponentName The component name of the task. Name is defined in
15  *   [OnboardingComponents].
16  */
17 data class OnboardingTaskToken(val taskContractClass: String, val taskComponentName: String) :
18   Parcelable {
19   constructor(
20     parcel: Parcel
21   ) : this(
22     taskContractClass = parcel.readString() ?: error("taskContractClass is missing in the parcel"),
23     taskComponentName = parcel.readString() ?: error("taskComponentName is missing in the parcel"),
24   )
25 
writeToParcelnull26   override fun writeToParcel(parcel: Parcel, flags: Int) {
27     parcel.writeString(taskContractClass)
28     parcel.writeString(taskComponentName)
29   }
30 
describeContentsnull31   override fun describeContents(): Int = 0
32 
33   companion object CREATOR : Parcelable.Creator<OnboardingTaskToken> {
34     const val INVALID_STRING = "INVALID"
35     // Constant representing an invalid token
36     val INVALID: OnboardingTaskToken =
37       OnboardingTaskToken(taskContractClass = INVALID_STRING, taskComponentName = INVALID_STRING)
38 
39     override fun createFromParcel(parcel: Parcel): OnboardingTaskToken {
40       return OnboardingTaskToken(parcel)
41     }
42 
43     override fun newArray(size: Int): Array<OnboardingTaskToken?> {
44       return arrayOfNulls(size)
45     }
46   }
47 }
48