ProfileVerifier.CompilationStatus


class ProfileVerifier.CompilationStatus


CompilationStatus contains the result of a profile verification operation. It offers API to determine whether a profile was installed getProfileInstallResultCode and to check whether the app has been compiled with a profile or a profile is enqueued for compilation. Note that the app can be compiled with a profile also as result of background dex optimization.

Summary

Constants

const Int

Indicates that a profile is installed and the app has been compiled with it.

const Int

Indicates that a profile is installed and the app has been compiled with it.

const Int

Indicates that a previous verification result cache file exists but it cannot be read.

const Int

Indicates that wasn't possible to write the verification result cache file.

const Int

Indicates that the apk does not embed a baseline profile.

const Int

Indicates an error during the verification process: a PackageManager.NameNotFoundException was launched when querying the PackageManager for the app package.

const Int

Indicates that ProfileVerifier runs on an unsupported api version of Android.

const Int

This property is deprecated.

Do not use.

const Int

Indicates that no profile was installed for this app when installing the app through an app store or package manager.

const Int

Indicates that a profile is installed and the app will be compiled with it later when background dex optimization runs (i.e when the device is in idle and connected to the power).

Constants

RESULT_CODE_COMPILED_WITH_PROFILE

Added in 1.3.0
const val RESULT_CODE_COMPILED_WITH_PROFILE = 1: Int

Indicates that a profile is installed and the app has been compiled with it. This is the result of installation through app store or package manager, or installation through profile installer and subsequent compilation during background dex optimization.

RESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING

Added in 1.3.0
const val RESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING = 3: Int

Indicates that a profile is installed and the app has been compiled with it. This is the result of installation through app store or package manager. Note that this result differs from RESULT_CODE_COMPILED_WITH_PROFILE as the profile is smaller than expected and may not include all the methods initially included in the baseline profile.

RESULT_CODE_ERROR_CACHE_FILE_EXISTS_BUT_CANNOT_BE_READ

Added in 1.3.0
const val RESULT_CODE_ERROR_CACHE_FILE_EXISTS_BUT_CANNOT_BE_READ = 131072: Int

Indicates that a previous verification result cache file exists but it cannot be read.

RESULT_CODE_ERROR_CANT_WRITE_PROFILE_VERIFICATION_RESULT_CACHE_FILE

Added in 1.3.0
const val RESULT_CODE_ERROR_CANT_WRITE_PROFILE_VERIFICATION_RESULT_CACHE_FILE = 196608: Int

Indicates that wasn't possible to write the verification result cache file. This can happen only because something is wrong with app folder permissions or if there is no free disk space on the device.

RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED

Added in 1.4.1
const val RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED = 327680: Int

Indicates that the apk does not embed a baseline profile. When this happens it's usually because a baseline profile was not found at build time. Baseline profiles can be generated through the Baseline Profile Gradle Plugin, or manually added to the baseline profile source set for AGP 8.0 and above, or manually placed in `src/main/baseline-prof.txt for versions of AGP less than to 8.0 (legacy behavior that does not support variants).

RESULT_CODE_ERROR_PACKAGE_NAME_DOES_NOT_EXIST

Added in 1.3.0
const val RESULT_CODE_ERROR_PACKAGE_NAME_DOES_NOT_EXIST = 65536: Int

Indicates an error during the verification process: a PackageManager.NameNotFoundException was launched when querying the PackageManager for the app package.

RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION

Added in 1.3.0
const val RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION = 262144: Int

Indicates that ProfileVerifier runs on an unsupported api version of Android. Note that ProfileVerifier supports only P and above. Note that when this result code is returned isCompiledWithProfile and hasProfileEnqueuedForCompilation return false.

RESULT_CODE_NO_PROFILE

Added in 1.3.0
Deprecated in 1.4.1
const val RESULT_CODE_NO_PROFILE = 0: Int

Indicates that no profile was installed for this app. This means that no profile was installed when installing the app through app store or package manager and profile installer either didn't run (ProfileInstallerInitializer disabled) or the app was packaged without a compilation profile.

RESULT_CODE_NO_PROFILE_INSTALLED

Added in 1.4.1
const val RESULT_CODE_NO_PROFILE_INSTALLED = 0: Int

Indicates that no profile was installed for this app when installing the app through an app store or package manager. The main reason for this to error code is that the profile installer did not run due to ProfileInstallerInitializer being disabled. Note that when this error is reported an embedded profile was still found in the application apk. When an embedded profile is not found, the error code returned is RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED.

RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION

Added in 1.3.0
const val RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION = 2: Int

Indicates that a profile is installed and the app will be compiled with it later when background dex optimization runs (i.e when the device is in idle and connected to the power). This is the result of installation through profile installer. When the profile is compiled, the result code will change to RESULT_CODE_COMPILED_WITH_PROFILE. Note that to test that the app is compiled with the installed profile, the background dex optimization can be forced through the following adb shell command: ``` adb shell cmd package compile -f -m speed-profile ```

Public functions

appApkHasEmbeddedProfile

Added in 1.4.1
fun appApkHasEmbeddedProfile(): Boolean
Returns
Boolean

True when the application apk has an embedded profile in the assets, false otherwise. Note that if the profile is not embedded, the result code is always RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED.

getProfileInstallResultCode

Added in 1.3.0
fun getProfileInstallResultCode(): Int
Returns
Int

a result code that indicates whether there is a baseline profile installed and whether the app has been compiled with it. This depends on the installation method: if it was installed through app store or package manager the app gets compiled immediately with the profile and the return code is RESULT_CODE_COMPILED_WITH_PROFILE, otherwise it'll be in `awaiting compilation` state and it'll be compiled at some point later in the future, so the return code will be RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION. In the case that no profile was installed, the result code will be RESULT_CODE_NO_PROFILE_INSTALLED. Note that even if no profile was installed it's still possible for the app to have a profile and be compiled with it, as result of background dex optimization. The result code does a simple size check to ensure the compilation process completed without errors. If the size check fails this method will return RESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING. The size check is not 100% accurate as the actual compiled methods are not checked. If something fails during the verification process, this method will return one of the result codes associated with an error. Note that only api 28 P and above is supported and that RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION is returned when calling this api on pre api 28.

hasProfileEnqueuedForCompilation

Added in 1.3.0
fun hasProfileEnqueuedForCompilation(): Boolean
Returns
Boolean

True whether this app has a profile enqueued for compilation, false otherwise. An app can have a profile enqueued for compilation because of profile installation through profileinstaller or simply when the user starts interacting with the app. Note that if getProfileInstallResultCode returns RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION this method always returns false.

isCompiledWithProfile

Added in 1.3.0
fun isCompiledWithProfile(): Boolean
Returns
Boolean

True whether this app has been compiled with a profile, false otherwise. An app can be compiled with a profile because of profile installation through app store, package manager or profileinstaller and subsequent background dex optimization. There should be a performance improvement when an app has been compiled with a profile. Note that if getProfileInstallResultCode returns RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION this method always returns always false.