xref: /aosp_15_r20/external/android_onboarding/java/com/android/onboarding/versions/OnboardingChanges.kt (revision c625018464ae97c56936c82b1b617e11aa899faa)
1 package com.android.onboarding.versions
2 
3 import com.android.onboarding.versions.annotations.ChangeRadius
4 import com.android.onboarding.versions.annotations.ValidChangeId
5 import java.lang.UnsupportedOperationException
6 
7 /** Entry point to checking if processes support particular change ids. */
8 interface OnboardingChanges {
9 
10   /** True if the current executing process supports the given change ID. */
currentProcessSupportsChangenull11   fun currentProcessSupportsChange(@ValidChangeId changeId: Long): Boolean
12 
13   /**
14    * Throws an [UnsupportedOperationException] if the current executing process does not support the
15    * given change ID.
16    */
17   fun requireCurrentProcessSupportsChange(@ValidChangeId changeId: Long)
18 
19   /**
20    * True if the given component supports the given change ID.
21    *
22    * If the component has not had [loadSupportedChanges] called previously, then it will be called
23    * now. It is recommended that [loadSupportedChanges] is called ahead-of-time for all relevant
24    * components to avoid arbitrary delays.
25    *
26    * If the component does not exist or is not valid, then it is assumed to support all released
27    * changes but no unreleased changes.
28    */
29   fun componentSupportsChange(
30     component: String,
31     @ValidChangeId(
32       allowedChangeRadii = [ChangeRadius.MULTI_COMPONENT],
33       disallowedChangeRadiiError =
34         "You cannot query changes which are SINGLE_COMPONENT across process boundaries.",
35     )
36     changeId: Long,
37   ): Boolean
38 
39   /**
40    * Load the supported changes for the given component.
41    *
42    * This call involves IPC, and should ideally be performed in the background ahead of time.
43    */
44   fun loadSupportedChanges(component: String)
45 }
46