ProfileVerifier

public final class ProfileVerifier


Provides API to verify whether a compilation profile was installed with the app. This does not make a distinction between cloud or baseline profile. The output of getCompilationStatusAsync allows to check if the app has been compiled with a compiled profile or whether there is a profile enqueued for compilation. If ProfileInstallerInitializer was disabled, it's necessary to manually trigger the method writeProfileVerification or the ListenableFuture returned by getCompilationStatusAsync will hang or timeout. Note that ProfileVerifier requires P due to a permission issue: the reference profile folder is not accessible to pre api 28. When calling this api on unsupported api, getCompilationStatusAsync returns RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION. The same permission issue exists also on R so also in that case the api returns RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION.

Summary

Nested types

CompilationStatus contains the result of a profile verification operation.

Public methods

static @NonNull ListenableFuture<ProfileVerifier.CompilationStatus>

Returns a future containing the CompilationStatus of the app profile.

static @NonNull ProfileVerifier.CompilationStatus

Caches the information on whether a reference profile exists for this app.

Public methods

getCompilationStatusAsync

Added in 1.3.0
public static @NonNull ListenableFuture<ProfileVerifier.CompilationStatusgetCompilationStatusAsync()

Returns a future containing the CompilationStatus of the app profile. The CompilationStatus can be used to determine whether a baseline or cloud profile is installed either through app store or package manager (reference profile) or profile installer (current profile), in order to tag performance metrics versions. In the first case a reference profile is immediately installed, i.e. a the app has been compiled with a profile. In the second case the profile is awaiting compilation that will happen at some point later in background.

writeProfileVerification

Added in 1.3.0
@WorkerThread
public static @NonNull ProfileVerifier.CompilationStatus writeProfileVerification(@NonNull Context context)

Caches the information on whether a reference profile exists for this app. This method performs IO operations and should not be executed on main thread. Note that this method should be called manually a few seconds after app startup if ProfileInstallerInitializer has been disabled.

Parameters
@NonNull Context context

an instance of the Context.

Returns
@NonNull ProfileVerifier.CompilationStatus

the CompilationStatus of the app profile. Note that this is the same CompilationStatus obtained through getCompilationStatusAsync.