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

Commit e8df5cd9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I0b5152d7,I00a6f1cd

* changes:
  Temporary debugging
  Remove scanPackageInternal()
parents 0b224978 c170e20c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -811,6 +811,8 @@ public class PackageParser {

    public static final int PARSE_MUST_BE_APK = 1 << 0;
    public static final int PARSE_IGNORE_PROCESSES = 1 << 1;
    /** @deprecated forward lock no longer functional. remove. */
    @Deprecated
    public static final int PARSE_FORWARD_LOCK = 1 << 2;
    public static final int PARSE_EXTERNAL_STORAGE = 1 << 3;
    public static final int PARSE_IS_SYSTEM_DIR = 1 << 4;
@@ -6001,6 +6003,8 @@ public class PackageParser {
            }
        }

        /** @deprecated Forward locked apps no longer supported. Resource path not needed. */
        @Deprecated
        public void setApplicationInfoResourcePath(String resourcePath) {
            this.applicationInfo.setResourcePath(resourcePath);
            if (childPackages != null) {
@@ -6011,6 +6015,8 @@ public class PackageParser {
            }
        }

        /** @deprecated Forward locked apps no longer supported. Resource path not needed. */
        @Deprecated
        public void setApplicationInfoBaseResourcePath(String resourcePath) {
            this.applicationInfo.setBaseResourcePath(resourcePath);
            if (childPackages != null) {
@@ -6059,6 +6065,8 @@ public class PackageParser {
            // Children have no splits
        }

        /** @deprecated Forward locked apps no longer supported. Resource path not needed. */
        @Deprecated
        public void setApplicationInfoSplitResourcePaths(String[] resroucePaths) {
            this.applicationInfo.setSplitResourcePaths(resroucePaths);
            // Children have no splits
+341 −276

File changed.

Preview size limit exceeded, changes collapsed.

+29 −0
Original line number Diff line number Diff line
@@ -97,6 +97,35 @@ public final class PackageSetting extends PackageSettingBase {
            + " " + name + "/" + appId + "}";
    }

    // Temporary to catch potential issues with refactoring
    public String dumpState_temp() {
        String flags = "";
        flags += ((pkgFlags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0 ? "U" : "");
        flags += ((pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0 ? "S" : "");
        if ("".equals(flags)) {
            flags = "-";
        }
        String privFlags = "";
        privFlags += ((pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0 ? "P" : "");
        privFlags += ((pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0 ? "O" : "");
        privFlags += ((pkgPrivateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0 ? "V" : "");
        if ("".equals(privFlags)) {
            privFlags = "-";
        }
        return "PackageSetting{"
                + Integer.toHexString(System.identityHashCode(this))
                + " " + name + (realName == null ? "" : "("+realName+")") + "/" + appId + (sharedUser==null?"":" u:" + sharedUser.name+"("+sharedUserId+")")
                + ", ver:" + versionCode
                + ", path: " + codePath
                + ", pABI: " + primaryCpuAbiString
                + ", sABI: " + secondaryCpuAbiString
                + ", oABI: " + cpuAbiOverrideString
                + ", flags: " + flags
                + ", privFlags: " + privFlags
                + ", pkg: " + (pkg == null ? "<<NULL>>" : "{" + Integer.toHexString(System.identityHashCode(pkg)) + "}")
                + "}";
    }

    public void copyFrom(PackageSetting orig) {
        super.copyFrom(orig);
        doCopy(orig);
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.pm;

import android.content.pm.PackageParser;
import android.content.pm.Signature;
import android.content.pm.PackageParser.SigningDetails;
import android.os.Environment;
import android.util.Slog;
import android.util.Xml;
@@ -451,7 +452,8 @@ final class Policy {
    public String getMatchedSeInfo(PackageParser.Package pkg) {
        // Check for exact signature matches across all certs.
        Signature[] certs = mCerts.toArray(new Signature[0]);
        if (!Signature.areExactMatch(certs, pkg.mSigningDetails.signatures)) {
        if (pkg.mSigningDetails != SigningDetails.UNKNOWN
                && !Signature.areExactMatch(certs, pkg.mSigningDetails.signatures)) {
            return null;
        }

+45 −95
Original line number Diff line number Diff line
@@ -785,11 +785,12 @@ public final class Settings {
     */
    static void updatePackageSetting(@NonNull PackageSetting pkgSetting,
            @Nullable PackageSetting disabledPkg, @Nullable SharedUserSetting sharedUser,
            @NonNull File codePath, @Nullable String legacyNativeLibraryPath,
            @Nullable String primaryCpuAbi, @Nullable String secondaryCpuAbi,
            int pkgFlags, int pkgPrivateFlags, @Nullable List<String> childPkgNames,
            @NonNull UserManagerService userManager, @Nullable String[] usesStaticLibraries,
            @Nullable long[] usesStaticLibrariesVersions) throws PackageManagerException {
            @NonNull File codePath, File resourcePath,
            @Nullable String legacyNativeLibraryPath, @Nullable String primaryCpuAbi,
            @Nullable String secondaryCpuAbi, int pkgFlags, int pkgPrivateFlags,
            @Nullable List<String> childPkgNames, @NonNull UserManagerService userManager,
            @Nullable String[] usesStaticLibraries, @Nullable long[] usesStaticLibrariesVersions)
                    throws PackageManagerException {
        final String pkgName = pkgSetting.name;
        if (pkgSetting.sharedUser != sharedUser) {
            PackageManagerService.reportSettingsProblem(Log.WARN,
@@ -801,29 +802,19 @@ public final class Settings {
        }

        if (!pkgSetting.codePath.equals(codePath)) {
            // Check to see if its a disabled system app
            if ((pkgSetting.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                // This is an updated system app with versions in both system
                // and data partition. Just let the most recent version
                // take precedence.
                Slog.w(PackageManagerService.TAG,
                        "Trying to update system app code path from "
                        + pkgSetting.codePathString + " to " + codePath.toString());
            } else {
                // Just a change in the code path is not an issue, but
                // let's log a message about it.
            final boolean isSystem = pkgSetting.isSystem();
            Slog.i(PackageManagerService.TAG,
                        "Package " + pkgName + " codePath changed from "
                        + pkgSetting.codePath + " to " + codePath
                        + "; Retaining data and using new");

                // The owner user's installed flag is set false
                // when the application was installed by other user
                // and the installed flag is not updated
                // when the application is appended as system app later.
                if ((pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0
                        && disabledPkg == null) {
                    List<UserInfo> allUserInfos = getAllUsers(userManager);
                    "Update" + (isSystem ? " system" : "")
                    + " package " + pkgName
                    + " code path from " + pkgSetting.codePathString
                    + " to " + codePath.toString()
                    + "; Retain data and using new");
            if (!isSystem) {
                // The package isn't considered as installed if the application was
                // first installed by another user. Update the installed flag when the
                // application ever becomes part of the system.
                if ((pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0 && disabledPkg == null) {
                    final List<UserInfo> allUserInfos = getAllUsers(userManager);
                    if (allUserInfos != null) {
                        for (UserInfo userInfo : allUserInfos) {
                            pkgSetting.setInstalled(true, userInfo.id);
@@ -831,14 +822,24 @@ public final class Settings {
                    }
                }

                /*
                 * Since we've changed paths, we need to prefer the new
                 * native library path over the one stored in the
                 * package settings since we might have moved from
                 * internal to external storage or vice versa.
                 */
                // Since we've changed paths, prefer the new native library path over
                // the one stored in the package settings since we might have moved from
                // internal to external storage or vice versa.
                pkgSetting.legacyNativeLibraryPathString = legacyNativeLibraryPath;
            }
            pkgSetting.codePath = codePath;
            pkgSetting.codePathString = codePath.toString();
        }
        if (!pkgSetting.resourcePath.equals(resourcePath)) {
            final boolean isSystem = pkgSetting.isSystem();
            Slog.i(PackageManagerService.TAG,
                    "Update" + (isSystem ? " system" : "")
                    + " package " + pkgName
                    + " resource path from " + pkgSetting.resourcePathString
                    + " to " + resourcePath.toString()
                    + "; Retain data and using new");
            pkgSetting.resourcePath = resourcePath;
            pkgSetting.resourcePathString = resourcePath.toString();
        }
        // If what we are scanning is a system (and possibly privileged) package,
        // then make it so, regardless of whether it was previously installed only
@@ -855,13 +856,14 @@ public final class Settings {
        if (childPkgNames != null) {
            pkgSetting.childPackageNames = new ArrayList<>(childPkgNames);
        }
        if (usesStaticLibraries != null) {
            pkgSetting.usesStaticLibraries = Arrays.copyOf(usesStaticLibraries,
                    usesStaticLibraries.length);
        }
        if (usesStaticLibrariesVersions != null) {
            pkgSetting.usesStaticLibrariesVersions = Arrays.copyOf(usesStaticLibrariesVersions,
                    usesStaticLibrariesVersions.length);
        // Update static shared library dependencies if needed
        if (usesStaticLibraries != null && usesStaticLibrariesVersions != null
                && usesStaticLibraries.length == usesStaticLibrariesVersions.length) {
            pkgSetting.usesStaticLibraries = usesStaticLibraries;
            pkgSetting.usesStaticLibrariesVersions = usesStaticLibrariesVersions;
        } else {
            pkgSetting.usesStaticLibraries = null;
            pkgSetting.usesStaticLibrariesVersions = null;
        }
    }

@@ -914,70 +916,18 @@ public final class Settings {
                userId);
    }

    // TODO: Move to scanPackageOnlyLI() after verifying signatures are setup correctly
    // by that time.
    void insertPackageSettingLPw(PackageSetting p, PackageParser.Package pkg) {
        p.pkg = pkg;
        // pkg.mSetEnabled = p.getEnabled(userId);
        // pkg.mSetStopped = p.getStopped(userId);
        final String volumeUuid = pkg.applicationInfo.volumeUuid;
        final String codePath = pkg.applicationInfo.getCodePath();
        final String resourcePath = pkg.applicationInfo.getResourcePath();
        final String legacyNativeLibraryPath = pkg.applicationInfo.nativeLibraryRootDir;
        // Update volume if needed
        if (!Objects.equals(volumeUuid, p.volumeUuid)) {
            Slog.w(PackageManagerService.TAG, "Volume for " + p.pkg.packageName +
                    " changing from " + p.volumeUuid + " to " + volumeUuid);
            p.volumeUuid = volumeUuid;
        }
        // Update code path if needed
        if (!Objects.equals(codePath, p.codePathString)) {
            Slog.w(PackageManagerService.TAG, "Code path for " + p.pkg.packageName +
                    " changing from " + p.codePathString + " to " + codePath);
            p.codePath = new File(codePath);
            p.codePathString = codePath;
        }
        //Update resource path if needed
        if (!Objects.equals(resourcePath, p.resourcePathString)) {
            Slog.w(PackageManagerService.TAG, "Resource path for " + p.pkg.packageName +
                    " changing from " + p.resourcePathString + " to " + resourcePath);
            p.resourcePath = new File(resourcePath);
            p.resourcePathString = resourcePath;
        }
        // Update the native library paths if needed
        if (!Objects.equals(legacyNativeLibraryPath, p.legacyNativeLibraryPathString)) {
            p.legacyNativeLibraryPathString = legacyNativeLibraryPath;
        }

        // Update the required Cpu Abi
        p.primaryCpuAbiString = pkg.applicationInfo.primaryCpuAbi;
        p.secondaryCpuAbiString = pkg.applicationInfo.secondaryCpuAbi;
        p.cpuAbiOverrideString = pkg.cpuAbiOverride;
        // Update version code if needed
        if (pkg.getLongVersionCode() != p.versionCode) {
            p.versionCode = pkg.getLongVersionCode();
        }
        // Update signatures if needed.
        if (p.signatures.mSignatures == null) {
            p.signatures.assignSignatures(pkg.mSigningDetails);
        }
        // Update flags if needed.
        if (pkg.applicationInfo.flags != p.pkgFlags) {
            p.pkgFlags = pkg.applicationInfo.flags;
        }
        // If this app defines a shared user id initialize
        // the shared user signatures as well.
        if (p.sharedUser != null && p.sharedUser.signatures.mSignatures == null) {
            p.sharedUser.signatures.assignSignatures(pkg.mSigningDetails);
        }
        // Update static shared library dependencies if needed
        if (pkg.usesStaticLibraries != null && pkg.usesStaticLibrariesVersions != null
                && pkg.usesStaticLibraries.size() == pkg.usesStaticLibrariesVersions.length) {
            p.usesStaticLibraries = new String[pkg.usesStaticLibraries.size()];
            pkg.usesStaticLibraries.toArray(p.usesStaticLibraries);
            p.usesStaticLibrariesVersions = pkg.usesStaticLibrariesVersions;
        } else {
            p.usesStaticLibraries = null;
            p.usesStaticLibrariesVersions = null;
        }
        addPackageSettingLPw(p, p.sharedUser);
    }

Loading