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

Commit c87545bf authored by Winson Chiu's avatar Winson Chiu
Browse files

Add CPU ABI fallback directly into PackageState

To simplify the external API, the raw package ABI won't be exposed,
only the overridden/device configured value available through the
PackageState object.

However, changing the default fallback behavior would also change
the value that existing callers get within system server.

It's difficult to audit whether or not each caller needs the fallback
or not, so the behavior was maintained with separate
getPrimaryCpuAbiLegacy and getSecondaryCpuAbiLegacy methods. These
should gradually be removed as the callers' needs can be identified.

Bug: 225395398

Test: atest PackageManagerSettingsTests
Test: atest ScanTests

Change-Id: Ibdf49d700ab6f21afa5a61c66f47dc2844b6cd45
parent d39c6774
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -298,7 +298,8 @@ final class AppDataHelper {
            // Create a native library symlink only if we have native libraries
            // and if the native libraries are 32 bit libraries. We do not provide
            // this symlink for 64 bit libraries.
            String primaryCpuAbi = AndroidPackageUtils.getPrimaryCpuAbi(pkg, pkgSetting);
            String primaryCpuAbi = pkgSetting == null
                    ? AndroidPackageUtils.getRawPrimaryCpuAbi(pkg) : pkgSetting.getPrimaryCpuAbi();
            if (primaryCpuAbi != null && !VMRuntime.is64BitAbi(primaryCpuAbi)) {
                final String nativeLibPath = pkg.getNativeLibraryDir();
                if (!(new File(nativeLibPath).exists())) {
+2 −2
Original line number Diff line number Diff line
@@ -1674,8 +1674,8 @@ public class ComputerEngine implements Computer {
            ApplicationInfo ai = new ApplicationInfo();
            ai.packageName = ps.getPackageName();
            ai.uid = UserHandle.getUid(userId, ps.getAppId());
            ai.primaryCpuAbi = ps.getPrimaryCpuAbi();
            ai.secondaryCpuAbi = ps.getSecondaryCpuAbi();
            ai.primaryCpuAbi = ps.getPrimaryCpuAbiLegacy();
            ai.secondaryCpuAbi = ps.getSecondaryCpuAbiLegacy();
            ai.setVersionCode(ps.getVersionCode());
            ai.flags = ps.getFlags();
            ai.privateFlags = ps.getPrivateFlags();
+1 −1
Original line number Diff line number Diff line
@@ -573,7 +573,7 @@ final class DeletePackageHelper {
        if (deleteCodeAndResources && (outInfo != null)) {
            outInfo.mArgs = new InstallArgs(
                    ps.getPathString(), getAppDexInstructionSets(
                            ps.getPrimaryCpuAbi(), ps.getSecondaryCpuAbi()));
                            ps.getPrimaryCpuAbiLegacy(), ps.getSecondaryCpuAbiLegacy()));
            if (DEBUG_SD_INSTALL) Slog.i(TAG, "args=" + outInfo.mArgs);
        }
    }
+2 −3
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.server.pm.dex.DexManager;
import com.android.server.pm.dex.DexoptOptions;
import com.android.server.pm.parsing.pkg.AndroidPackageUtils;
import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.PackageStateInternal;

@@ -470,8 +469,8 @@ final class DexOptHelper {
        // others will see that the compiled code for the library is up to date.
        Collection<SharedLibraryInfo> deps = SharedLibraryUtils.findSharedLibraries(pkgSetting);
        final String[] instructionSets = getAppDexInstructionSets(
                AndroidPackageUtils.getPrimaryCpuAbi(p, pkgSetting),
                AndroidPackageUtils.getSecondaryCpuAbi(p, pkgSetting));
                pkgSetting.getPrimaryCpuAbi(),
                pkgSetting.getSecondaryCpuAbi());
        if (!deps.isEmpty()) {
            DexoptOptions libraryOptions = new DexoptOptions(options.getPackageName(),
                    options.getCompilationReason(), options.getCompilerFilter(),
+7 −9
Original line number Diff line number Diff line
@@ -1377,8 +1377,8 @@ final class InstallPackageHelper {

                // We moved the entire application as-is, so bring over the
                // previously derived ABI information.
                parsedPackage.setPrimaryCpuAbi(ps.getPrimaryCpuAbi())
                        .setSecondaryCpuAbi(ps.getSecondaryCpuAbi());
                parsedPackage.setPrimaryCpuAbi(ps.getPrimaryCpuAbiLegacy())
                        .setSecondaryCpuAbi(ps.getSecondaryCpuAbiLegacy());
            }

        } else {
@@ -1932,10 +1932,8 @@ final class InstallPackageHelper {
                        installRequest.getRemovedInfo().mArgs = new InstallArgs(
                                oldPackage.getPath(),
                                getAppDexInstructionSets(
                                        AndroidPackageUtils.getPrimaryCpuAbi(oldPackage,
                                                deletedPkgSetting),
                                        AndroidPackageUtils.getSecondaryCpuAbi(oldPackage,
                                                deletedPkgSetting)));
                                        deletedPkgSetting.getPrimaryCpuAbi(),
                                        deletedPkgSetting.getSecondaryCpuAbi()));
                    } else {
                        installRequest.getRemovedInfo().mArgs = null;
                    }
@@ -3944,8 +3942,8 @@ final class InstallPackageHelper {

            mRemovePackageHelper.cleanUpResources(
                    new File(pkgSetting.getPathString()),
                    getAppDexInstructionSets(pkgSetting.getPrimaryCpuAbi(),
                            pkgSetting.getSecondaryCpuAbi()));
                    getAppDexInstructionSets(pkgSetting.getPrimaryCpuAbiLegacy(),
                            pkgSetting.getSecondaryCpuAbiLegacy()));
            synchronized (mPm.mLock) {
                mPm.mSettings.enableSystemPackageLPw(pkgSetting.getPackageName());
            }
@@ -4029,7 +4027,7 @@ final class InstallPackageHelper {
                                + parsedPackage.getPath());
                mRemovePackageHelper.cleanUpResources(new File(pkgSetting.getPathString()),
                        getAppDexInstructionSets(
                                pkgSetting.getPrimaryCpuAbi(), pkgSetting.getSecondaryCpuAbi()));
                                pkgSetting.getPrimaryCpuAbiLegacy(), pkgSetting.getSecondaryCpuAbiLegacy()));
            } else {
                // The application on /system is older than the application on /data. Hide
                // the application on /system and the version on /data will be scanned later
Loading