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

Commit 874b11a9 authored by Songchun Fan's avatar Songchun Fan
Browse files

[SharedUserSetting] fix copying for snapshot

BUG: 216207402
Test: builds
Change-Id: I43820eb195547d2970a645eed6512475408e0b99
parent c7c5ed70
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1382,7 +1382,7 @@ public class AppsFilter implements Watchable, Snappable {
                }
            } else {
                callingPkgSetting = null;
                callingSharedPkgSettings = ((SharedUserSetting) callingSetting).packages;
                callingSharedPkgSettings = ((SharedUserSetting) callingSetting).getPackageStates();
            }
            if (DEBUG_TRACING) {
                Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
+19 −10
Original line number Diff line number Diff line
@@ -2176,11 +2176,13 @@ public class ComputerEngine implements Computer {
                return null;
            }
            final SharedUserSetting sus = (SharedUserSetting) obj;
            final int n = sus.packages.size();
            final ArraySet<PackageStateInternal> packageStates =
                    (ArraySet<PackageStateInternal>) sus.getPackageStates();
            final int n = packageStates.size();
            String[] res = new String[n];
            int i = 0;
            for (int index = 0; index < n; index++) {
                final PackageStateInternal ps = sus.packages.valueAt(index);
                final PackageStateInternal ps = packageStates.valueAt(index);
                if (ps.getUserStateOrDefault(userId).isInstalled()
                        && !shouldFilterApplication(ps, callingUid, userId)) {
                    res[i++] = ps.getPackageName();
@@ -2710,8 +2712,10 @@ public class ComputerEngine implements Computer {
    public final boolean shouldFilterApplication(@NonNull SharedUserSetting sus,
            int callingUid, int userId) {
        boolean filterApp = true;
        for (int index = sus.packages.size() - 1; index >= 0 && filterApp; index--) {
            filterApp &= shouldFilterApplication(sus.packages.valueAt(index),
        final ArraySet<PackageStateInternal> packageStates =
                (ArraySet<PackageStateInternal>) sus.getPackageStates();
        for (int index = packageStates.size() - 1; index >= 0 && filterApp; index--) {
            filterApp &= shouldFilterApplication(packageStates.valueAt(index),
                    callingUid, /* component */ null, TYPE_UNKNOWN, userId);
        }
        return filterApp;
@@ -4468,9 +4472,11 @@ public class ComputerEngine implements Computer {
        final Object obj = mSettings.getSettingBase(appId);
        if (obj instanceof SharedUserSetting) {
            final SharedUserSetting sus = (SharedUserSetting) obj;
            final int numPackages = sus.packages.size();
            final ArraySet<PackageStateInternal> packageStates =
                    (ArraySet<PackageStateInternal>) sus.getPackageStates();
            final int numPackages = packageStates.size();
            for (int index = 0; index < numPackages; index++) {
                final PackageSetting ps = sus.packages.valueAt(index);
                final PackageStateInternal ps = packageStates.valueAt(index);
                if (ps.isPrivileged()) {
                    return true;
                }
@@ -5290,8 +5296,9 @@ public class ComputerEngine implements Computer {
            final AndroidPackage pkg = ((PackageSetting) setting).getPkg();
            return pkg != null && mAppsFilter.canQueryPackage(pkg, targetPackageName);
        } else {
            final ArraySet<PackageSetting> callingSharedPkgSettings =
                    ((SharedUserSetting) setting).packages;
            final ArraySet<PackageStateInternal> callingSharedPkgSettings =
                    (ArraySet<PackageStateInternal>)
                            ((SharedUserSetting) setting).getPackageStates();
            for (int i = callingSharedPkgSettings.size() - 1; i >= 0; i--) {
                final AndroidPackage pkg = callingSharedPkgSettings.valueAt(i).getPkg();
                if (pkg != null && mAppsFilter.canQueryPackage(pkg, targetPackageName)) {
@@ -5595,10 +5602,12 @@ public class ComputerEngine implements Computer {
        final SettingBase settingBase = mSettings.getSettingBase(appId);
        if (settingBase instanceof SharedUserSetting) {
            final SharedUserSetting sus = (SharedUserSetting) settingBase;
            final ArraySet<PackageStateInternal> packageStates =
                    (ArraySet<PackageStateInternal>) sus.getPackageStates();
            int vers = Build.VERSION_CODES.CUR_DEVELOPMENT;
            final int numPackages = sus.packages.size();
            final int numPackages = packageStates.size();
            for (int index = 0; index < numPackages; index++) {
                final PackageSetting ps = sus.packages.valueAt(index);
                final PackageStateInternal ps = packageStates.valueAt(index);
                if (ps.getPkg() != null) {
                    int v = ps.getPkg().getTargetSdkVersion();
                    if (v < vers) vers = v;
+1 −1
Original line number Diff line number Diff line
@@ -3701,7 +3701,7 @@ final class InstallPackageHelper {
                    && sharedUserSetting != null) {
                Log.d(TAG, "Shared UserID " + parsedPackage.getSharedUserId()
                        + " (uid=" + sharedUserSetting.mAppId + "):"
                        + " packages=" + sharedUserSetting.packages);
                        + " packages=" + sharedUserSetting.getPackageStates());
            }
            if (installedPkgSetting != null) {
                oldSharedUserSetting = mPm.mSettings.getSharedUserSettingLPr(installedPkgSetting);
+4 −3
Original line number Diff line number Diff line
@@ -18,15 +18,16 @@ package com.android.server.pm;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.ArraySet;
import android.util.Pair;

import com.android.internal.annotations.VisibleForTesting;
import com.android.server.pm.parsing.pkg.AndroidPackage;
import com.android.server.pm.parsing.pkg.AndroidPackageUtils;
import com.android.server.pm.parsing.pkg.ParsedPackage;
import com.android.server.pm.pkg.PackageStateInternal;

import java.io.File;
import java.util.Set;



@@ -74,8 +75,8 @@ public interface PackageAbiHelper {
     *         belonging to the shared user.
     */
    @Nullable
    String getAdjustedAbiForSharedUser(
            Set<PackageSetting> packagesForUser, AndroidPackage scannedPackage);
    String getAdjustedAbiForSharedUser(ArraySet<? extends PackageStateInternal> packagesForUser,
            AndroidPackage scannedPackage);

    /**
     * The native library paths and related properties that should be set on a
+6 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.os.Environment;
import android.os.FileUtils;
import android.os.Trace;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Pair;
import android.util.Slog;

@@ -41,6 +42,7 @@ import com.android.internal.content.NativeLibraryHelper;
import com.android.internal.util.ArrayUtils;
import com.android.server.pm.parsing.pkg.AndroidPackage;
import com.android.server.pm.parsing.pkg.AndroidPackageUtils;
import com.android.server.pm.pkg.PackageStateInternal;

import dalvik.system.VMRuntime;

@@ -48,7 +50,6 @@ import libcore.io.IoUtils;

import java.io.File;
import java.io.IOException;
import java.util.Set;

final class PackageAbiHelperImpl implements PackageAbiHelper {

@@ -496,7 +497,8 @@ final class PackageAbiHelperImpl implements PackageAbiHelper {
    @Override
    @Nullable
    public String getAdjustedAbiForSharedUser(
            Set<PackageSetting> packagesForUser, AndroidPackage scannedPackage) {
            ArraySet<? extends PackageStateInternal> packagesForUser,
            AndroidPackage scannedPackage) {
        String requiredInstructionSet = null;
        if (scannedPackage != null) {
            String pkgRawPrimaryCpuAbi = AndroidPackageUtils.getRawPrimaryCpuAbi(scannedPackage);
@@ -505,8 +507,8 @@ final class PackageAbiHelperImpl implements PackageAbiHelper {
            }
        }

        PackageSetting requirer = null;
        for (PackageSetting ps : packagesForUser) {
        PackageStateInternal requirer = null;
        for (PackageStateInternal ps : packagesForUser) {
            // If packagesForUser contains scannedPackage, we skip it. This will happen
            // when scannedPackage is an update of an existing package. Without this check,
            // we will never be able to change the ABI of any package belonging to a shared
Loading