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

Commit 2ab076f6 authored by Nicolas Geoffray's avatar Nicolas Geoffray
Browse files

Drop REASON_SHARED_APK.

This reason was only used by "system shared libraries", not shared
APKs like GMS.

Code that uses this reason is now obsolete, as we do compile these shared
libraries when we see an apk that uses it.

bug:33799337
Test: m -j32 && boot
Change-Id: I2eef22797551401a5c39ed339bc2486cf0d091a8
(cherry picked from commit 86d1e9e2)
parent 8d686949
Loading
Loading
Loading
Loading
+1 −55
Original line number Diff line number Diff line
@@ -537,8 +537,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    public static final int REASON_INSTALL = 2;
    public static final int REASON_BACKGROUND_DEXOPT = 3;
    public static final int REASON_AB_OTA = 4;
    public static final int REASON_SHARED_APK = 5;
    public static final int REASON_FORCED_DEXOPT = 6;
    public static final int REASON_FORCED_DEXOPT = 5;
    public static final int REASON_LAST = REASON_FORCED_DEXOPT;
@@ -2376,59 +2375,6 @@ public class PackageManagerService extends IPackageManager.Stub {
                Slog.w(TAG, "No SYSTEMSERVERCLASSPATH found!");
            }
            final List<String> allInstructionSets = InstructionSets.getAllInstructionSets();
            final String[] dexCodeInstructionSets =
                    getDexCodeInstructionSets(
                            allInstructionSets.toArray(new String[allInstructionSets.size()]));
            /**
             * Ensure all external libraries have had dexopt run on them.
             */
            if (mSharedLibraries.size() > 0) {
                Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "dexopt");
                // NOTE: For now, we're compiling these system "shared libraries"
                // (and framework jars) into all available architectures. It's possible
                // to compile them only when we come across an app that uses them (there's
                // already logic for that in scanPackageLI) but that adds some complexity.
                for (String dexCodeInstructionSet : dexCodeInstructionSets) {
                    final int libCount = mSharedLibraries.size();
                    for (int i = 0; i < libCount; i++) {
                        SparseArray<SharedLibraryEntry> versionedLib = mSharedLibraries.valueAt(i);
                        final int versionCount = versionedLib.size();
                        for (int j = 0; j < versionCount; j++) {
                            SharedLibraryEntry libEntry = versionedLib.valueAt(j);
                            final String libPath = libEntry.path != null
                                    ? libEntry.path : libEntry.apk;
                            if (libPath == null) {
                                continue;
                            }
                            try {
                                // Shared libraries do not have profiles so we perform a full
                                // AOT compilation (if needed).
                                int dexoptNeeded = DexFile.getDexOptNeeded(
                                        libPath, dexCodeInstructionSet,
                                        getCompilerFilterForReason(REASON_SHARED_APK),
                                        false /* newProfile */);
                                if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) {
                                    mInstaller.dexopt(libPath, Process.SYSTEM_UID, "*",
                                            dexCodeInstructionSet, dexoptNeeded, null,
                                            DEXOPT_PUBLIC,
                                            getCompilerFilterForReason(REASON_SHARED_APK),
                                            StorageManager.UUID_PRIVATE_INTERNAL,
                                            PackageDexOptimizer.SKIP_SHARED_LIBRARY_CHECK);
                                }
                            } catch (FileNotFoundException e) {
                                Slog.w(TAG, "Library not found: " + libPath);
                            } catch (IOException | InstallerException e) {
                                Slog.w(TAG, "Cannot dexopt " + libPath + "; is it an APK or JAR? "
                                        + e.getMessage());
                            }
                        }
                    }
                }
                Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
            }
            File frameworkDir = new File(Environment.getRootDirectory(), "framework");
            final VersionInfo ver = mSettings.getInternalVersion();
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import dalvik.system.DexFile;
public class PackageManagerServiceCompilerMapping {
    // Names for compilation reasons.
    static final String REASON_STRINGS[] = {
            "first-boot", "boot", "install", "bg-dexopt", "ab-ota", "shared-apk", "forced-dexopt"
            "first-boot", "boot", "install", "bg-dexopt", "ab-ota", "forced-dexopt"
    };

    // Static block to ensure the strings array is of the right length.
@@ -56,7 +56,6 @@ public class PackageManagerServiceCompilerMapping {

        // Ensure that some reasons are not mapped to profile-guided filters.
        switch (reason) {
            case PackageManagerService.REASON_SHARED_APK:
            case PackageManagerService.REASON_FORCED_DEXOPT:
                if (DexFile.isProfileGuidedCompilerFilter(sysPropValue)) {
                    throw new IllegalStateException("\"" + sysPropValue + "\" is profile-guided, "