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

Commit 99e31bc6 authored by Pedro Loureiro's avatar Pedro Loureiro Committed by Automerger Merge Worker
Browse files

Merge "Allow unknown codenames in target sdk version for APK-in-apexes" into...

Merge "Allow unknown codenames in target sdk version for APK-in-apexes" into tm-dev am: e748d40d am: 86e71dc8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17238066



Change-Id: I4c5ab19d1b99e8c0eff3b4fc179a58d915085ad6
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 84d8b1de 86e71dc8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -324,6 +324,7 @@ java_defaults {
        "av-types-aidl-java",
        "tv_tuner_resource_manager_aidl_interface-java",
        "soundtrigger_middleware-aidl-java",
        "modules-utils-build",
        "modules-utils-preconditions",
        "modules-utils-synchronous-result-receiver",
        "modules-utils-os",
+2 −1
Original line number Diff line number Diff line
@@ -568,7 +568,8 @@ public class ApkLiteParseUtils {
                }

                ParseResult<Integer> targetResult = FrameworkParsingPackageUtils.computeTargetSdkVersion(
                        targetVer, targetCode, SDK_CODENAMES, input);
                        targetVer, targetCode, SDK_CODENAMES, input,
                        /* allowUnknownCodenames= */ false);
                if (targetResult.isError()) {
                    return input.error(targetResult);
                }
+20 −8
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.util.Slog;
import android.util.apk.ApkSignatureVerifier;

import com.android.internal.util.ArrayUtils;
import com.android.modules.utils.build.UnboundedSdkLevel;

import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
@@ -334,8 +335,9 @@ public class FrameworkParsingPackageUtils {
     * If {@code targetCode} is not specified, e.g. the value is {@code null}, then the {@code
     * targetVers} will be returned unmodified.
     * <p>
     * Otherwise, the behavior varies based on whether the current platform is a pre-release
     * version, e.g. the {@code platformSdkCodenames} array has length > 0:
     * When {@code allowUnknownCodenames} is false, the behavior varies based on whether the
     * current platform is a pre-release version, e.g. the {@code platformSdkCodenames} array has
     * length > 0:
     * <ul>
     * <li>If this is a pre-release platform and the value specified by
     * {@code targetCode} is contained within the array of allowed pre-release
@@ -343,22 +345,32 @@ public class FrameworkParsingPackageUtils {
     * <li>If this is a released platform, this method will return -1 to
     * indicate that the package is not compatible with this platform.
     * </ul>
     * <p>
     * When {@code allowUnknownCodenames} is true, any codename that is not known (presumed to be
     * a codename announced after the build of the current device) is allowed and this method will
     * return {@link Build.VERSION_CODES#CUR_DEVELOPMENT}.
     *
     * @param targetVers            targetSdkVersion number, if specified in the application
     *                              manifest, or 0 otherwise
     * @param targetCode            targetSdkVersion code, if specified in the application manifest,
     *                              or {@code null} otherwise
     * @param platformSdkCodenames  array of allowed pre-release SDK codenames for this platform
     * @param allowUnknownCodenames allow unknown codenames, if true this method will accept unknown
     *                              (presumed to be future) codenames
     * @return the targetSdkVersion to use at runtime if successful
     */
    public static ParseResult<Integer> computeTargetSdkVersion(@IntRange(from = 0) int targetVers,
            @Nullable String targetCode, @NonNull String[] platformSdkCodenames,
            @NonNull ParseInput input) {
            @NonNull ParseInput input, boolean allowUnknownCodenames) {
        // If it's a release SDK, return the version number unmodified.
        if (targetCode == null) {
            return input.success(targetVers);
        }

        if (allowUnknownCodenames && UnboundedSdkLevel.isAtMost(targetCode)) {
            return input.success(Build.VERSION_CODES.CUR_DEVELOPMENT);
        }

        // If it's a pre-release SDK and the codename matches this platform, it
        // definitely targets this SDK.
        if (matchTargetCode(platformSdkCodenames, targetCode)) {
+3 −0
Original line number Diff line number Diff line
@@ -5,3 +5,6 @@ rule android.hidl.** android.internal.hidl.@1
# Framework-specific renames.
rule android.net.wifi.WifiAnnotations* android.internal.wifi.WifiAnnotations@1
rule com.android.server.vcn.util.** com.android.server.vcn.repackaged.util.@1

# for modules-utils-build dependency
rule com.android.modules.utils.build.** android.internal.modules.utils.build.@1
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import static com.android.server.pm.PackageManagerService.SCAN_NO_DEX;
import static com.android.server.pm.PackageManagerService.SCAN_REQUIRE_KNOWN;
import static com.android.server.pm.PackageManagerService.SYSTEM_PARTITIONS;
import static com.android.server.pm.PackageManagerService.TAG;
import static com.android.server.pm.pkg.parsing.ParsingPackageUtils.PARSE_CHECK_MAX_SDK_VERSION;
import static com.android.server.pm.pkg.parsing.ParsingPackageUtils.PARSE_APK_IN_APEX;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -359,7 +359,7 @@ final class InitAppsHelper {
        try {
            if ((scanFlags & SCAN_AS_APK_IN_APEX) != 0) {
                // when scanning apk in apexes, we want to check the maxSdkVersion
                parseFlags |= PARSE_CHECK_MAX_SDK_VERSION;
                parseFlags |= PARSE_APK_IN_APEX;
            }
            mInstallPackageHelper.installPackagesFromDir(scanDir, frameworkSplits, parseFlags,
                    scanFlags, packageParser, executorService);
Loading