ProfileInstaller

public class ProfileInstaller
extends Object

java.lang.Object
   ↳ androidx.profileinstaller.ProfileInstaller


Install ahead of time tracing profiles to configure ART to precompile bundled libraries. This will automatically be called by ProfileInstallerInitializer and you should never call this unless you have disabled the initializer in your manifest. This reads profiles from the assets directory, where they must be embedded during the build process. This will have no effect if there is not a profile embedded in the current APK.

Summary

Nested classes

interface ProfileInstaller.DiagnosticsCallback

An object which can be passed to the ProfileInstaller which will receive information during the installation process which can be used for logging and telemetry. 

Constants

int DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST

Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.

int DIAGNOSTIC_CURRENT_PROFILE_EXISTS

Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory.

int DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST

Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.

int DIAGNOSTIC_REF_PROFILE_EXISTS

Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory.

int RESULT_ALREADY_INSTALLED

Indicates that no installation occurred because it was determined that the baseline profile had already been installed previously.

int RESULT_BASELINE_PROFILE_NOT_FOUND

Indicates that no baseline profile was bundled with the APK, and as a result, no installation could take place.

int RESULT_DESIRED_FORMAT_UNSUPPORTED

Indicates that the format required by this SDK version is not supported by this version of the ProfileInstaller library.

int RESULT_INSTALL_SUCCESS

Indicates that the profile got installed and written to disk successfully.

int RESULT_IO_EXCEPTION

Indicates that an IO Exception took place during install.

int RESULT_NOT_WRITABLE

Indicates that the installation was aborted because the app was found to not have adequate permissions to write the profile to disk.

int RESULT_PARSE_EXCEPTION

Indicates that a parsing exception occurred during install.

int RESULT_UNSUPPORTED_ART_VERSION

Indicates that the current SDK level is such that installing a profile is not supported by ART.

Public methods

static void writeProfile(Context context)

Try to write the profile from assets into the ART aot profile directory.

static void writeProfile(Context context, Executor executor, ProfileInstaller.DiagnosticsCallback diagnostics)

Try to write the profile from assets into the ART aot profile directory.

Inherited methods

Constants

DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST

public static final int DIAGNOSTIC_CURRENT_PROFILE_DOES_NOT_EXIST

Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.

Constant Value: 2 (0x00000002)

DIAGNOSTIC_CURRENT_PROFILE_EXISTS

public static final int DIAGNOSTIC_CURRENT_PROFILE_EXISTS

Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory. The associated [data] passed in for this call will be the size, in bytes, of the profile that was found.

Constant Value: 1 (0x00000001)

DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST

public static final int DIAGNOSTIC_REF_PROFILE_DOES_NOT_EXIST

Indicates that when tryInstallSync was run, no existing profile was found in the "cur" directory.

Constant Value: 4 (0x00000004)

DIAGNOSTIC_REF_PROFILE_EXISTS

public static final int DIAGNOSTIC_REF_PROFILE_EXISTS

Indicates that when tryInstallSync was run, an existing profile was found in the "cur" directory. The associated [data] passed in for this call will be the size, in bytes, of the profile that was found.

Constant Value: 3 (0x00000003)

RESULT_ALREADY_INSTALLED

public static final int RESULT_ALREADY_INSTALLED

Indicates that no installation occurred because it was determined that the baseline profile had already been installed previously.

Constant Value: 2 (0x00000002)

RESULT_BASELINE_PROFILE_NOT_FOUND

public static final int RESULT_BASELINE_PROFILE_NOT_FOUND

Indicates that no baseline profile was bundled with the APK, and as a result, no installation could take place.

Constant Value: 6 (0x00000006)

RESULT_DESIRED_FORMAT_UNSUPPORTED

public static final int RESULT_DESIRED_FORMAT_UNSUPPORTED

Indicates that the format required by this SDK version is not supported by this version of the ProfileInstaller library.

Constant Value: 5 (0x00000005)

RESULT_INSTALL_SUCCESS

public static final int RESULT_INSTALL_SUCCESS

Indicates that the profile got installed and written to disk successfully. Note that this should happen but is not the only condition that indicates "nothing went wrong". Several result codes are indicative of expected behavior.

Constant Value: 1 (0x00000001)

RESULT_IO_EXCEPTION

public static final int RESULT_IO_EXCEPTION

Indicates that an IO Exception took place during install. The associated [data] with this result is the exception.

Constant Value: 7 (0x00000007)

RESULT_NOT_WRITABLE

public static final int RESULT_NOT_WRITABLE

Indicates that the installation was aborted because the app was found to not have adequate permissions to write the profile to disk.

Constant Value: 4 (0x00000004)

RESULT_PARSE_EXCEPTION

public static final int RESULT_PARSE_EXCEPTION

Indicates that a parsing exception occurred during install. The associated [data] with this result is the exception.

Constant Value: 8 (0x00000008)

RESULT_UNSUPPORTED_ART_VERSION

public static final int RESULT_UNSUPPORTED_ART_VERSION

Indicates that the current SDK level is such that installing a profile is not supported by ART.

Constant Value: 3 (0x00000003)

Public methods

writeProfile

public static void writeProfile (Context context)

Try to write the profile from assets into the ART aot profile directory. You do not need to call this method if ProfileInstallerInitializer is enabled for your application. If you disable the initializer, you should call this method within 5-10 seconds of app launch, to ensure that art can use the generated profile. This should always be called after the first screen is shown to the user, to avoid delaying application startup to install AOT profiles. It is encouraged that you call this method during every app startup to ensure profiles are written correctly after app upgrades, or if the profile failed to write on the previous launch. Profiles will be correctly formatted based on the current API level of the device, and only installed if profileinstaller can determine that it is safe to do so. If the profile is not written, no action needs to be taken.

Parameters
context Context: context to read assets from

writeProfile

public static void writeProfile (Context context, 
                Executor executor, 
                ProfileInstaller.DiagnosticsCallback diagnostics)

Try to write the profile from assets into the ART aot profile directory. You do not need to call this method if ProfileInstallerInitializer is enabled for your application. If you disable the initializer, you should call this method within 5-10 seconds of app launch, to ensure that art can use the generated profile. This should always be called after the first screen is shown to the user, to avoid delaying application startup to install AOT profiles. It is encouraged that you call this method during every app startup to ensure profiles are written correctly after app upgrades, or if the profile failed to write on the previous launch. Profiles will be correctly formatted based on the current API level of the device, and only installed if profileinstaller can determine that it is safe to do so. If the profile is not written, no action needs to be taken.

Parameters
context Context: context to read assets from

executor Executor: the executor to run the diagnostic events through

diagnostics ProfileInstaller.DiagnosticsCallback: an object which will receive diagnostic information about the installation