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

Commit 9a2b1b35 authored by Winson's avatar Winson
Browse files

Use PackageInfoUtils with null PackageSetting to set server-only flags

PackageImpl on the server side contains fields that are system server
specific, such as what partition the package was found on. These
fields are hidden from the core side, since they're irrelevant
for APKs that are not processed by PackageManagerService.

To mirror this, only the server side PackageInfoUtils sets the
flags related to theses server-side fields.

So when a PackageSetting is created, this server-side
PackageInfoUtils must be called, not the core side
PackageInfoWithoutStateUtils, with a null PackageSetting,
to set the related pkg(Private)Flags.

Bug: 150083410

Test: atest android.cts.backup.OtherSoundsSettingsHostSideTest
Test: atest com.android.server.pm.parsing

Change-Id: Ife39c83e243daf5d3583f04fce1c0f87c0e20585
parent 5b55f124
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -213,7 +213,6 @@ import android.content.pm.VersionedPackage;
import android.content.pm.dex.ArtManager;
import android.content.pm.dex.DexMetadataHelper;
import android.content.pm.dex.IArtManager;
import android.content.pm.parsing.PackageInfoWithoutStateUtils;
import android.content.pm.parsing.ParsingPackageUtils;
import android.content.pm.parsing.component.ParsedActivity;
import android.content.pm.parsing.component.ParsedInstrumentation;
@@ -10951,17 +10950,22 @@ public class PackageManagerService extends IPackageManager.Stub
        if (createNewPackage) {
            final boolean instantApp = (scanFlags & SCAN_AS_INSTANT_APP) != 0;
            final boolean virtualPreload = (scanFlags & SCAN_AS_VIRTUAL_PRELOAD) != 0;
            // Flags contain system values stored in the server variant of AndroidPackage,
            // and so the server-side PackageInfoUtils is still called, even without a
            // PackageSetting to pass in.
            int pkgFlags = PackageInfoUtils.appInfoFlags(parsedPackage, null);
            int pkgPrivateFlags = PackageInfoUtils.appInfoPrivateFlags(parsedPackage, null);
            // REMOVE SharedUserSetting from method; update in a separate call
            pkgSetting = Settings.createNewSetting(parsedPackage.getPackageName(),
                    originalPkgSetting, disabledPkgSetting, realPkgName, sharedUserSetting,
                    destCodeFile, destResourceFile, parsedPackage.getNativeLibraryRootDir(),
                    AndroidPackageUtils.getRawPrimaryCpuAbi(parsedPackage),
                    AndroidPackageUtils.getRawSecondaryCpuAbi(parsedPackage),
                    parsedPackage.getVersionCode(),
                    PackageInfoWithoutStateUtils.appInfoFlags(parsedPackage),
                    PackageInfoWithoutStateUtils.appInfoPrivateFlags(parsedPackage),
                    user, true /*allowInstall*/, instantApp,
                    virtualPreload, UserManagerService.getInstance(), usesStaticLibraries,
                    parsedPackage.getVersionCode(), pkgFlags, pkgPrivateFlags, user,
                    true /*allowInstall*/, instantApp, virtualPreload,
                    UserManagerService.getInstance(), usesStaticLibraries,
                    parsedPackage.getUsesStaticLibrariesVersions(), parsedPackage.getMimeGroups());
        } else {
            // make a deep copy to avoid modifying any existing system state.