public class

ProfileVerifier.CompilationStatus

extends java.lang.Object

 java.lang.Object

↳androidx.profileinstaller.ProfileVerifier.CompilationStatus

Overview

ProfileVerifier.CompilationStatus contains the result of a profile verification operation. It offers API to determine whether a profile was installed ProfileVerifier.CompilationStatus.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

Fields
public static final intRESULT_CODE_COMPILED_WITH_PROFILE

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

public static final intRESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING

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

public static final intRESULT_CODE_ERROR_CACHE_FILE_EXISTS_BUT_CANNOT_BE_READ

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

public static final intRESULT_CODE_ERROR_CANT_WRITE_PROFILE_VERIFICATION_RESULT_CACHE_FILE

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

public static final intRESULT_CODE_ERROR_NO_PROFILE_EMBEDDED

Indicates that the apk does not embed a baseline profile.

public static final intRESULT_CODE_ERROR_PACKAGE_NAME_DOES_NOT_EXIST

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

public static final intRESULT_CODE_ERROR_UNSUPPORTED_API_VERSION

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

public static final intRESULT_CODE_NO_PROFILE

Indicates that no profile was installed for this app.

public static final intRESULT_CODE_NO_PROFILE_INSTALLED

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

public static final intRESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION

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).

Methods
public booleanappApkHasEmbeddedProfile()

public intgetProfileInstallResultCode()

public booleanhasProfileEnqueuedForCompilation()

public booleanisCompiledWithProfile()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int RESULT_CODE_NO_PROFILE_INSTALLED

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 ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED.

public static final int RESULT_CODE_NO_PROFILE

Deprecated: Do not use. Use ProfileVerifier.CompilationStatus.RESULT_CODE_NO_PROFILE_INSTALLED instead.

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.

public static final int RESULT_CODE_COMPILED_WITH_PROFILE

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.

public static final int RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION

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 ProfileVerifier.CompilationStatus.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 static final int RESULT_CODE_COMPILED_WITH_PROFILE_NON_MATCHING

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 ProfileVerifier.CompilationStatus.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.

public static final int RESULT_CODE_ERROR_PACKAGE_NAME_DOES_NOT_EXIST

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

public static final int RESULT_CODE_ERROR_CACHE_FILE_EXISTS_BUT_CANNOT_BE_READ

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

public static final int RESULT_CODE_ERROR_CANT_WRITE_PROFILE_VERIFICATION_RESULT_CACHE_FILE

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.

public static final int RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION

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

public static final int RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED

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).

Methods

public int getProfileInstallResultCode()

Returns:

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 ProfileVerifier.CompilationStatus.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 ProfileVerifier.CompilationStatus.RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION. In the case that no profile was installed, the result code will be ProfileVerifier.CompilationStatus.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 ProfileVerifier.CompilationStatus.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 and above is supported and that ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION is returned when calling this api on pre api 28.

public boolean isCompiledWithProfile()

Returns:

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 ProfileVerifier.CompilationStatus.getProfileInstallResultCode() returns ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION this method always returns always false.

public boolean hasProfileEnqueuedForCompilation()

Returns:

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 ProfileVerifier.CompilationStatus.getProfileInstallResultCode() returns ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION this method always returns false.

public boolean appApkHasEmbeddedProfile()

Returns:

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 ProfileVerifier.CompilationStatus.RESULT_CODE_ERROR_NO_PROFILE_EMBEDDED.