Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4103281f authored by Calin Juravle's avatar Calin Juravle
Browse files

Annotate the compilation reason with dex metadata information

Test: manual, adb logcat -b events | grep sysui_multi_action
Bug: 111699831

Change-Id: I9ae1f802404e5d1af50b060c448913153abc3ba4
parent 3261b948
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.util.Slog;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.pm.Installer.InstallerException;
import com.android.server.pm.dex.ArtManagerService;
import com.android.server.pm.dex.DexManager;
import com.android.server.pm.dex.DexoptOptions;
import com.android.server.pm.dex.DexoptUtils;
@@ -289,7 +290,8 @@ public class PackageDexOptimizer {
            mInstaller.dexopt(path, uid, pkg.packageName, isa, dexoptNeeded, oatDir, dexoptFlags,
                    compilerFilter, pkg.volumeUuid, classLoaderContext, pkg.applicationInfo.seInfo,
                    false /* downgrade*/, pkg.applicationInfo.targetSdkVersion,
                    profileName, dexMetadataPath, getReasonName(compilationReason));
                    profileName, dexMetadataPath,
                    getAugmentedReasonName(compilationReason, dexMetadataPath != null));

            if (packageStats != null) {
                long endTime = System.currentTimeMillis();
@@ -302,6 +304,12 @@ public class PackageDexOptimizer {
        }
    }

    private String getAugmentedReasonName(int compilationReason, boolean useDexMetadata) {
        String annotation = useDexMetadata
                ? ArtManagerService.DEXOPT_REASON_WITH_DEX_METADATA_ANNOTATION : "";
        return getReasonName(compilationReason) + annotation;
    }

    /**
     * Performs dexopt on the secondary dex {@code path} belonging to the app {@code info}.
     *
+9 −0
Original line number Diff line number Diff line
@@ -519,6 +519,11 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
    private static final int TRON_COMPILATION_REASON_AB_OTA = 6;
    private static final int TRON_COMPILATION_REASON_INACTIVE = 7;
    private static final int TRON_COMPILATION_REASON_SHARED = 8;
    private static final int TRON_COMPILATION_REASON_INSTALL_WITH_DEX_METADATA = 9;

    // The annotation to add as a suffix to the compilation reason when dexopt was
    // performed with dex metadata.
    public static final String DEXOPT_REASON_WITH_DEX_METADATA_ANNOTATION = "-dm";

    /**
     * Convert the compilation reason to an int suitable to be logged to TRON.
@@ -534,6 +539,10 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
            case "ab-ota" : return TRON_COMPILATION_REASON_AB_OTA;
            case "inactive" : return TRON_COMPILATION_REASON_INACTIVE;
            case "shared" : return TRON_COMPILATION_REASON_SHARED;
            // This is a special marker for dex metadata installation that does not
            // have an equivalent as a system property.
            case "install" + DEXOPT_REASON_WITH_DEX_METADATA_ANNOTATION :
                return TRON_COMPILATION_REASON_INSTALL_WITH_DEX_METADATA;
            default: return TRON_COMPILATION_REASON_UNKNOWN;
        }
    }