# ProfileVerifier

Artifact: [androidx.profileinstaller:profileinstaller](https://developer.android.com/jetpack/androidx/releases/profileinstaller) [View Source](https://cs.android.com/search?q=file:androidx/profileinstaller/ProfileVerifier.java+class:androidx.profileinstaller.ProfileVerifier) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)

*** ** * ** ***

<br />

```
public final class ProfileVerifier
```

<br />

*** ** * ** ***

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 `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#getCompilationStatusAsync()` allows to check if the app has been compiled with a compiled profile or whether there is a profile enqueued for compilation. If `https://developer.android.com/reference/androidx/profileinstaller/ProfileInstallerInitializer` was disabled, it's necessary to manually trigger the method `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#writeProfileVerification(android.content.Context)` or the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` returned by `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#getCompilationStatusAsync()` will hang or timeout. Note that `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier` requires `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#P` due to a permission issue: the reference profile folder is not accessible to pre api 28. When calling this api on unsupported api, `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#getCompilationStatusAsync()` returns `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus#RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION()`. The same permission issue exists also on `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#R` so also in that case the api returns `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus#RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION()`.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` contains the result of a profile verification operation. |

| ### Public methods |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus>` | `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#getCompilationStatusAsync()()` Returns a future containing the `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` of the app profile. |
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#writeProfileVerification(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)` Caches the information on whether a reference profile exists for this app. |

## Public methods

### getCompilationStatusAsync

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#1.3.0)

```
public static @NonNull ListenableFuture<ProfileVerifier.CompilationStatus> getCompilationStatusAsync()
```

Returns a future containing the `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` of the app profile. The `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.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.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus>` | A future containing the `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus`. |

### writeProfileVerification

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/profileinstaller#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 `https://developer.android.com/reference/androidx/profileinstaller/ProfileInstallerInitializer` has been disabled.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | an instance of the `https://developer.android.com/reference/android/content/Context.html`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` | the `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` of the app profile. Note that this is the same `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier.CompilationStatus` obtained through `https://developer.android.com/reference/androidx/profileinstaller/ProfileVerifier#getCompilationStatusAsync()`. |