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

Commit 1d3dfdad authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Ib9172e79,I7b88d425 into sc-dev am: 3bbcb616

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iae58c7799a521f6e4e04465ed68479d6f0158228
parents 5a23f277 3bbcb616
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -23933,7 +23933,8 @@ public class PackageManagerService extends IPackageManager.Stub
                writer.println("Domain verification status:");
                writer.increaseIndent();
                try {
                    mDomainVerificationManager.printState(writer, packageName, UserHandle.USER_ALL);
                    mDomainVerificationManager.printState(writer, packageName, UserHandle.USER_ALL,
                            mSettings::getPackageLPr);
                } catch (PackageManager.NameNotFoundException e) {
                    pw.println("Failure printing domain verification information");
                    Slog.e(TAG, "Failure printing domain verification information", e);
+19 −4
Original line number Diff line number Diff line
@@ -32,15 +32,30 @@ import android.util.SparseArray;

import com.android.internal.util.CollectionUtils;
import com.android.server.pm.PackageSetting;
import com.android.server.pm.parsing.pkg.AndroidPackage;
import com.android.server.pm.verify.domain.models.DomainVerificationPkgState;
import com.android.server.pm.verify.domain.models.DomainVerificationStateMap;
import com.android.server.pm.verify.domain.models.DomainVerificationUserState;
import com.android.server.pm.parsing.pkg.AndroidPackage;

import java.util.Arrays;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;

@SuppressWarnings("PointlessBooleanExpression")
public class DomainVerificationDebug {

    // Disable to turn off all logging. This is used to allow a "basic" set of debug flags to be
    // enabled and checked in, without having everything be on or off.
    public static final boolean DEBUG_ANY = false;

    // Enable to turn on all logging. Requires enabling DEBUG_ANY.
    public static final boolean DEBUG_ALL = false;

    public static final boolean DEBUG_APPROVAL = DEBUG_ANY && (DEBUG_ALL || true);
    public static final boolean DEBUG_BROADCASTS = DEBUG_ANY && (DEBUG_ALL || false);
    public static final boolean DEBUG_PROXIES = DEBUG_ANY && (DEBUG_ALL || false);

    @NonNull
    private final DomainVerificationCollector mCollector;

@@ -50,7 +65,7 @@ public class DomainVerificationDebug {

    public void printState(@NonNull IndentingPrintWriter writer, @Nullable String packageName,
            @Nullable @UserIdInt Integer userId,
            @NonNull DomainVerificationService.Connection connection,
            @NonNull Function<String, PackageSetting> pkgSettingFunction,
            @NonNull DomainVerificationStateMap<DomainVerificationPkgState> stateMap)
            throws NameNotFoundException {
        ArrayMap<String, Integer> reusedMap = new ArrayMap<>();
@@ -61,7 +76,7 @@ public class DomainVerificationDebug {
            for (int index = 0; index < size; index++) {
                DomainVerificationPkgState pkgState = stateMap.valueAt(index);
                String pkgName = pkgState.getPackageName();
                PackageSetting pkgSetting = connection.getPackageSettingLocked(pkgName);
                PackageSetting pkgSetting = pkgSettingFunction.apply(pkgName);
                if (pkgSetting == null || pkgSetting.getPkg() == null) {
                    continue;
                }
@@ -77,7 +92,7 @@ public class DomainVerificationDebug {
                throw DomainVerificationUtils.throwPackageUnavailable(packageName);
            }

            PackageSetting pkgSetting = connection.getPackageSettingLocked(packageName);
            PackageSetting pkgSetting = pkgSettingFunction.apply(packageName);
            if (pkgSetting == null || pkgSetting.getPkg() == null) {
                throw DomainVerificationUtils.throwPackageUnavailable(packageName);
            }
+25 −6
Original line number Diff line number Diff line
@@ -32,15 +32,16 @@ import android.util.TypedXmlPullParser;
import android.util.TypedXmlSerializer;

import com.android.server.pm.PackageSetting;
import com.android.server.pm.parsing.pkg.AndroidPackage;
import com.android.server.pm.verify.domain.models.DomainVerificationPkgState;
import com.android.server.pm.verify.domain.proxy.DomainVerificationProxy;
import com.android.server.pm.parsing.pkg.AndroidPackage;

import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;

public interface DomainVerificationManagerInternal extends DomainVerificationManager {

@@ -191,12 +192,21 @@ public interface DomainVerificationManagerInternal extends DomainVerificationMan
    /**
     * Print the verification state and user selection state of a package.
     *
     * @param packageName the package whose state to change, or all packages if none is specified
     * @param packageName        the package whose state to change, or all packages if none is
     *                           specified
     * @param userId             the specific user to print, or null to skip printing user selection
     *                           states, supports {@link android.os.UserHandle#USER_ALL}
     * @param pkgSettingFunction the method by which to retrieve package data; if this is called
     *                           from {@link com.android.server.pm.PackageManagerService}, it is
     *                           expected to pass in the snapshot of {@link PackageSetting} objects,
     *                           or if null is passed, the manager may decide to lock {@link
     *                           com.android.server.pm.PackageManagerService} through {@link
     *                           Connection#getPackageSettingLocked(String)}
     */
    void printState(@NonNull IndentingPrintWriter writer, @Nullable String packageName,
            @Nullable @UserIdInt Integer userId) throws NameNotFoundException;
            @Nullable @UserIdInt Integer userId,
            @Nullable Function<String, PackageSetting> pkgSettingFunction)
            throws NameNotFoundException;

    @NonNull
    DomainVerificationShell getShell();
@@ -225,7 +235,7 @@ public interface DomainVerificationManagerInternal extends DomainVerificationMan
            throws IllegalArgumentException, NameNotFoundException;


    interface Connection {
    interface Connection extends Function<String, PackageSetting> {

        /**
         * Notify that a settings change has been made and that eventually
@@ -249,10 +259,19 @@ public interface DomainVerificationManagerInternal extends DomainVerificationMan
         */
        void schedule(int code, @Nullable Object object);

        // TODO(b/178733426): Make DomainVerificationService PMS snapshot aware so it can avoid
        //  locking package state at all. This can be as simple as removing this method in favor of
        //  accepting a PackageSetting function in at every method call, although should probably
        //  be abstracted to a wrapper class.
        @Nullable
        PackageSetting getPackageSettingLocked(@NonNull String pkgName);

        @Nullable
        AndroidPackage getPackageLocked(@NonNull String pkgName);

        @Override
        default PackageSetting apply(@NonNull String pkgName) {
            return getPackageSettingLocked(pkgName);
        }
    }
}
+19 −3
Original line number Diff line number Diff line
@@ -64,13 +64,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;

public class DomainVerificationService extends SystemService
        implements DomainVerificationManagerInternal, DomainVerificationShell.Callback {

    private static final String TAG = "DomainVerificationService";

    public static final boolean DEBUG_APPROVAL = true;
    public static final boolean DEBUG_APPROVAL = DomainVerificationDebug.DEBUG_APPROVAL;

    /**
     * The new user preference API for verifying domains marked autoVerify=true in
@@ -890,9 +891,24 @@ public class DomainVerificationService extends SystemService

    @Override
    public void printState(@NonNull IndentingPrintWriter writer, @Nullable String packageName,
            @Nullable @UserIdInt Integer userId) throws NameNotFoundException {
            @Nullable Integer userId) throws NameNotFoundException {
        // This method is only used by DomainVerificationShell, which doesn't lock PMS, so it's
        // safe to pass mConnection directly here and lock PMS. This method is not exposed
        // to the general system server/PMS.
        printState(writer, packageName, userId, mConnection);
    }

    @Override
    public void printState(@NonNull IndentingPrintWriter writer, @Nullable String packageName,
            @Nullable @UserIdInt Integer userId,
            @Nullable Function<String, PackageSetting> pkgSettingFunction)
            throws NameNotFoundException {
        if (pkgSettingFunction == null) {
            pkgSettingFunction = mConnection;
        }

        synchronized (mLock) {
            mDebug.printState(writer, packageName, userId, mConnection, mAttachedPkgStates);
            mDebug.printState(writer, packageName, userId, pkgSettingFunction, mAttachedPkgStates);
        }
    }

+3 −2
Original line number Diff line number Diff line
@@ -23,9 +23,10 @@ import android.content.Context;
import android.util.Slog;

import com.android.server.DeviceIdleInternal;
import com.android.server.pm.verify.domain.DomainVerificationMessageCodes;
import com.android.server.pm.verify.domain.DomainVerificationCollector;
import com.android.server.pm.verify.domain.DomainVerificationDebug;
import com.android.server.pm.verify.domain.DomainVerificationManagerInternal;
import com.android.server.pm.verify.domain.DomainVerificationMessageCodes;

import java.util.Objects;
import java.util.Set;
@@ -35,7 +36,7 @@ public interface DomainVerificationProxy {

    String TAG = "DomainVerificationProxy";

    boolean DEBUG_PROXIES = false;
    boolean DEBUG_PROXIES = DomainVerificationDebug.DEBUG_PROXIES;

    static <ConnectionType extends DomainVerificationProxyV1.Connection
            & DomainVerificationProxyV2.Connection> DomainVerificationProxy makeProxy(
Loading