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

Commit e448e546 authored by Winson's avatar Winson
Browse files

Rename to DomainVerificationInternalUserState

In anticipation of renaming the public API class, rename the internal
one to something that doesn't conflict, so that explicit imports or
aliases don't have to be used.

Bug: 181637637

Test: none, naming refactor

Change-Id: I2b2487265ba783a97697d1aff48568572e96ac3d
parent 5333c755
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ 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.verify.domain.models.DomainVerificationInternalUserState;

import java.util.Arrays;
import java.util.function.Function;
@@ -169,7 +169,7 @@ public class DomainVerificationDebug {
        }

        ArraySet<String> allWebDomains = mCollector.collectAllWebDomains(pkg);
        SparseArray<DomainVerificationUserState> userStates =
        SparseArray<DomainVerificationInternalUserState> userStates =
                pkgState.getUserSelectionStates();
        if (userId == UserHandle.USER_ALL) {
            int size = userStates.size();
@@ -178,13 +178,13 @@ public class DomainVerificationDebug {
                        wasHeaderPrinted);
            } else {
                for (int index = 0; index < size; index++) {
                    DomainVerificationUserState userState = userStates.valueAt(index);
                    DomainVerificationInternalUserState userState = userStates.valueAt(index);
                    printState(writer, pkgState, userState.getUserId(), userState, reusedSet,
                            allWebDomains, wasHeaderPrinted);
                }
            }
        } else {
            DomainVerificationUserState userState = userStates.get(userId);
            DomainVerificationInternalUserState userState = userStates.get(userId);
            printState(writer, pkgState, userId, userState, reusedSet, allWebDomains,
                    wasHeaderPrinted);
        }
@@ -192,8 +192,9 @@ public class DomainVerificationDebug {

    boolean printState(@NonNull IndentingPrintWriter writer,
            @NonNull DomainVerificationPkgState pkgState, @UserIdInt int userId,
            @Nullable DomainVerificationUserState userState, @NonNull ArraySet<String> reusedSet,
            @NonNull ArraySet<String> allWebDomains, boolean wasHeaderPrinted) {
            @Nullable DomainVerificationInternalUserState userState,
            @NonNull ArraySet<String> reusedSet, @NonNull ArraySet<String> allWebDomains,
            boolean wasHeaderPrinted) {
        reusedSet.clear();
        reusedSet.addAll(allWebDomains);
        if (userState != null) {
+8 −8
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import android.util.TypedXmlPullParser;
import android.util.TypedXmlSerializer;

import com.android.server.pm.SettingsXml;
import com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState;
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 org.xmlpull.v1.XmlPullParserException;

@@ -157,7 +157,7 @@ public class DomainVerificationPersistence {
        UUID id = UUID.fromString(idString);

        final ArrayMap<String, Integer> stateMap = new ArrayMap<>();
        final SparseArray<DomainVerificationUserState> userStates = new SparseArray<>();
        final SparseArray<DomainVerificationInternalUserState> userStates = new SparseArray<>();

        SettingsXml.ChildSection child = section.children();
        while (child.moveToNext()) {
@@ -176,10 +176,10 @@ public class DomainVerificationPersistence {
    }

    private static void readUserStates(@NonNull SettingsXml.ReadSection section,
            @NonNull SparseArray<DomainVerificationUserState> userStates) {
            @NonNull SparseArray<DomainVerificationInternalUserState> userStates) {
        SettingsXml.ChildSection child = section.children();
        while (child.moveToNext(TAG_USER_STATE)) {
            DomainVerificationUserState userState = createUserStateFromXml(child);
            DomainVerificationInternalUserState userState = createUserStateFromXml(child);
            if (userState != null) {
                userStates.put(userState.getUserId(), userState);
            }
@@ -210,7 +210,7 @@ public class DomainVerificationPersistence {
    }

    private static void writeUserStates(@NonNull SettingsXml.WriteSection parentSection,
            @NonNull SparseArray<DomainVerificationUserState> states) throws IOException {
            @NonNull SparseArray<DomainVerificationInternalUserState> states) throws IOException {
        int size = states.size();
        if (size == 0) {
            return;
@@ -245,7 +245,7 @@ public class DomainVerificationPersistence {
     * entered.
     */
    @Nullable
    public static DomainVerificationUserState createUserStateFromXml(
    public static DomainVerificationInternalUserState createUserStateFromXml(
            @NonNull SettingsXml.ReadSection section) {
        int userId = section.getInt(ATTR_USER_ID);
        if (userId == -1) {
@@ -260,7 +260,7 @@ public class DomainVerificationPersistence {
            readEnabledHosts(child, enabledHosts);
        }

        return new DomainVerificationUserState(userId, enabledHosts, allowLinkHandling);
        return new DomainVerificationInternalUserState(userId, enabledHosts, allowLinkHandling);
    }

    private static void readEnabledHosts(@NonNull SettingsXml.ReadSection section,
@@ -275,7 +275,7 @@ public class DomainVerificationPersistence {
    }

    public static void writeUserStateToXml(@NonNull SettingsXml.WriteSection parentSection,
            @NonNull DomainVerificationUserState userState) throws IOException {
            @NonNull DomainVerificationInternalUserState userState) throws IOException {
        try (SettingsXml.WriteSection section =
                     parentSection.startSection(TAG_USER_STATE)
                             .attribute(ATTR_USER_ID, userState.getUserId())
+17 −13
Original line number Diff line number Diff line
@@ -56,9 +56,9 @@ import com.android.server.SystemService;
import com.android.server.compat.PlatformCompat;
import com.android.server.pm.PackageSetting;
import com.android.server.pm.parsing.pkg.AndroidPackage;
import com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState;
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.verify.domain.proxy.DomainVerificationProxy;
import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyUnavailable;

@@ -405,7 +405,8 @@ public class DomainVerificationService extends SystemService
            final int size = mAttachedPkgStates.size();
            for (int index = 0; index < size; index++) {
                DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(index);
                SparseArray<DomainVerificationUserState> array = pkgState.getUserSelectionStates();
                SparseArray<DomainVerificationInternalUserState> array =
                        pkgState.getUserSelectionStates();
                int arraySize = array.size();
                for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) {
                    array.valueAt(arrayIndex).removeHost(domain);
@@ -484,7 +485,8 @@ public class DomainVerificationService extends SystemService

            DomainVerificationPkgState pkgState = getAndValidateAttachedLocked(domainSetId, domains,
                    false /* forAutoVerify */, callingUid, userId);
            DomainVerificationUserState userState = pkgState.getOrCreateUserSelectionState(userId);
            DomainVerificationInternalUserState userState =
                    pkgState.getOrCreateUserSelectionState(userId);

            // Disable other packages if approving this one. Note that this check is only done for
            // enabling. This allows an escape hatch in case multiple packages somehow get selected.
@@ -524,7 +526,7 @@ public class DomainVerificationService extends SystemService
                            continue;
                        }

                        DomainVerificationUserState approvedUserState =
                        DomainVerificationInternalUserState approvedUserState =
                                approvedPkgState.getUserSelectionState(userId);
                        if (approvedUserState == null) {
                            continue;
@@ -607,7 +609,7 @@ public class DomainVerificationService extends SystemService

        if (userId == UserHandle.USER_ALL) {
            for (int aUserId : mConnection.getAllUserIds()) {
                DomainVerificationUserState userState =
                DomainVerificationInternalUserState userState =
                        pkgState.getOrCreateUserSelectionState(aUserId);
                if (enabled) {
                    userState.addHosts(domains);
@@ -616,7 +618,8 @@ public class DomainVerificationService extends SystemService
                }
            }
        } else {
            DomainVerificationUserState userState = pkgState.getOrCreateUserSelectionState(userId);
            DomainVerificationInternalUserState userState =
                    pkgState.getOrCreateUserSelectionState(userId);
            if (enabled) {
                userState.addHosts(domains);
            } else {
@@ -649,7 +652,7 @@ public class DomainVerificationService extends SystemService

            Map<String, Integer> domains = new ArrayMap<>(webDomainsSize);
            ArrayMap<String, Integer> stateMap = pkgState.getStateMap();
            DomainVerificationUserState userState = pkgState.getUserSelectionState(userId);
            DomainVerificationInternalUserState userState = pkgState.getUserSelectionState(userId);
            Set<String> enabledHosts = userState == null ? emptySet() : userState.getEnabledHosts();

            for (int index = 0; index < webDomainsSize; index++) {
@@ -765,7 +768,7 @@ public class DomainVerificationService extends SystemService
            AndroidPackage newPkg = newPkgSetting.getPkg();

            ArrayMap<String, Integer> newStateMap = new ArrayMap<>();
            SparseArray<DomainVerificationUserState> newUserStates = new SparseArray<>();
            SparseArray<DomainVerificationInternalUserState> newUserStates = new SparseArray<>();

            if (oldPkgState == null || oldPkg == null || newPkg == null) {
                // Should be impossible, but to be safe, continue with a new blank state instead
@@ -808,7 +811,7 @@ public class DomainVerificationService extends SystemService
                }
            }

            SparseArray<DomainVerificationUserState> oldUserStates =
            SparseArray<DomainVerificationInternalUserState> oldUserStates =
                    oldPkgState.getUserSelectionStates();
            int oldUserStatesSize = oldUserStates.size();
            if (oldUserStatesSize > 0) {
@@ -816,13 +819,14 @@ public class DomainVerificationService extends SystemService
                for (int oldUserStatesIndex = 0; oldUserStatesIndex < oldUserStatesSize;
                        oldUserStatesIndex++) {
                    int userId = oldUserStates.keyAt(oldUserStatesIndex);
                    DomainVerificationUserState oldUserState = oldUserStates.valueAt(
                    DomainVerificationInternalUserState oldUserState = oldUserStates.valueAt(
                            oldUserStatesIndex);
                    ArraySet<String> oldEnabledHosts = oldUserState.getEnabledHosts();
                    ArraySet<String> newEnabledHosts = new ArraySet<>(oldEnabledHosts);
                    newEnabledHosts.retainAll(newWebDomains);
                    DomainVerificationUserState newUserState = new DomainVerificationUserState(
                            userId, newEnabledHosts, oldUserState.isLinkHandlingAllowed());
                    DomainVerificationInternalUserState newUserState =
                            new DomainVerificationInternalUserState(userId, newEnabledHosts,
                                    oldUserState.isLinkHandlingAllowed());
                    newUserStates.put(userId, newUserState);
                }
            }
@@ -1515,7 +1519,7 @@ public class DomainVerificationService extends SystemService
                return APPROVAL_LEVEL_NONE;
            }

            DomainVerificationUserState userState = pkgState.getUserSelectionState(userId);
            DomainVerificationInternalUserState userState = pkgState.getUserSelectionState(userId);

            if (userState != null && !userState.isLinkHandlingAllowed()) {
                if (DEBUG_APPROVAL) {
+7 −6
Original line number Diff line number Diff line
@@ -29,9 +29,9 @@ import android.util.TypedXmlSerializer;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState;
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 org.xmlpull.v1.XmlPullParserException;

@@ -216,21 +216,22 @@ class DomainVerificationSettings {
            }
        }

        SparseArray<DomainVerificationUserState> oldSelectionStates =
        SparseArray<DomainVerificationInternalUserState> oldSelectionStates =
                oldState.getUserSelectionStates();

        SparseArray<DomainVerificationUserState> newSelectionStates =
        SparseArray<DomainVerificationInternalUserState> newSelectionStates =
                newState.getUserSelectionStates();

        DomainVerificationUserState newUserState = newSelectionStates.get(UserHandle.USER_SYSTEM);
        DomainVerificationInternalUserState newUserState =
                newSelectionStates.get(UserHandle.USER_SYSTEM);
        if (newUserState != null) {
            ArraySet<String> newEnabledHosts = newUserState.getEnabledHosts();
            DomainVerificationUserState oldUserState =
            DomainVerificationInternalUserState oldUserState =
                    oldSelectionStates.get(UserHandle.USER_SYSTEM);

            boolean linkHandlingAllowed = newUserState.isLinkHandlingAllowed();
            if (oldUserState == null) {
                oldUserState = new DomainVerificationUserState(UserHandle.USER_SYSTEM,
                oldUserState = new DomainVerificationInternalUserState(UserHandle.USER_SYSTEM,
                        newEnabledHosts, linkHandlingAllowed);
                oldSelectionStates.put(UserHandle.USER_SYSTEM, oldUserState);
            } else {
+17 −18
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import java.util.Set;
 * when a web URL Intent is sent and the application is the highest priority for that domain.
 */
@DataClass(genSetters = true, genEqualsHashCode = true, genToString = true, genBuilder = false)
public class DomainVerificationUserState {
public class DomainVerificationInternalUserState {

    @UserIdInt
    private final int mUserId;
@@ -43,32 +43,32 @@ public class DomainVerificationUserState {
     */
    private boolean mLinkHandlingAllowed = true;

    public DomainVerificationUserState(@UserIdInt int userId) {
    public DomainVerificationInternalUserState(@UserIdInt int userId) {
        mUserId = userId;
        mEnabledHosts = new ArraySet<>();
    }

    public DomainVerificationUserState addHosts(@NonNull ArraySet<String> newHosts) {
    public DomainVerificationInternalUserState addHosts(@NonNull ArraySet<String> newHosts) {
        mEnabledHosts.addAll(newHosts);
        return this;
    }

    public DomainVerificationUserState addHosts(@NonNull Set<String> newHosts) {
    public DomainVerificationInternalUserState addHosts(@NonNull Set<String> newHosts) {
        mEnabledHosts.addAll(newHosts);
        return this;
    }

    public DomainVerificationUserState removeHost(String host) {
    public DomainVerificationInternalUserState removeHost(String host) {
        mEnabledHosts.remove(host);
        return this;
    }

    public DomainVerificationUserState removeHosts(@NonNull ArraySet<String> newHosts) {
    public DomainVerificationInternalUserState removeHosts(@NonNull ArraySet<String> newHosts) {
        mEnabledHosts.removeAll(newHosts);
        return this;
    }

    public DomainVerificationUserState removeHosts(@NonNull Set<String> newHosts) {
    public DomainVerificationInternalUserState removeHosts(@NonNull Set<String> newHosts) {
        mEnabledHosts.removeAll(newHosts);
        return this;
    }
@@ -81,8 +81,7 @@ public class DomainVerificationUserState {
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm
    // /verify/domain/models/DomainVerificationUserState.java
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationInternalUserState.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
@@ -90,7 +89,7 @@ public class DomainVerificationUserState {


    /**
     * Creates a new DomainVerificationUserState.
     * Creates a new DomainVerificationInternalUserState.
     *
     * @param enabledHosts
     *   List of domains which have been enabled by the user. *
@@ -98,7 +97,7 @@ public class DomainVerificationUserState {
     *   Whether to allow this package to automatically open links by auto verification.
     */
    @DataClass.Generated.Member
    public DomainVerificationUserState(
    public DomainVerificationInternalUserState(
            @UserIdInt int userId,
            @NonNull ArraySet<String> enabledHosts,
            boolean linkHandlingAllowed) {
@@ -138,7 +137,7 @@ public class DomainVerificationUserState {
     * Whether to allow this package to automatically open links by auto verification.
     */
    @DataClass.Generated.Member
    public @NonNull DomainVerificationUserState setLinkHandlingAllowed( boolean value) {
    public @NonNull DomainVerificationInternalUserState setLinkHandlingAllowed( boolean value) {
        mLinkHandlingAllowed = value;
        return this;
    }
@@ -149,7 +148,7 @@ public class DomainVerificationUserState {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "DomainVerificationUserState { " +
        return "DomainVerificationInternalUserState { " +
                "userId = " + mUserId + ", " +
                "enabledHosts = " + mEnabledHosts + ", " +
                "linkHandlingAllowed = " + mLinkHandlingAllowed +
@@ -160,13 +159,13 @@ public class DomainVerificationUserState {
    @DataClass.Generated.Member
    public boolean equals(@android.annotation.Nullable Object o) {
        // You can override field equality logic by defining either of the methods like:
        // boolean fieldNameEquals(DomainVerificationUserState other) { ... }
        // boolean fieldNameEquals(DomainVerificationInternalUserState other) { ... }
        // boolean fieldNameEquals(FieldType otherValue) { ... }

        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        @SuppressWarnings("unchecked")
        DomainVerificationUserState that = (DomainVerificationUserState) o;
        DomainVerificationInternalUserState that = (DomainVerificationInternalUserState) o;
        //noinspection PointlessBooleanExpression
        return true
                && mUserId == that.mUserId
@@ -188,10 +187,10 @@ public class DomainVerificationUserState {
    }

    @DataClass.Generated(
            time = 1612894390039L,
            time = 1614714563905L,
            codegenVersion = "1.0.22",
            sourceFile = "frameworks/base/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationUserState.java",
            inputSignatures = "private final @android.annotation.UserIdInt int mUserId\nprivate final @android.annotation.NonNull android.util.ArraySet<java.lang.String> mEnabledHosts\nprivate  boolean mLinkHandlingAllowed\npublic  com.android.server.pm.verify.domain.models.DomainVerificationUserState addHosts(android.util.ArraySet<java.lang.String>)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationUserState addHosts(java.util.Set<java.lang.String>)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationUserState removeHosts(android.util.ArraySet<java.lang.String>)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationUserState removeHosts(java.util.Set<java.lang.String>)\nclass DomainVerificationUserState extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genSetters=true, genEqualsHashCode=true, genToString=true, genBuilder=false)")
            sourceFile = "frameworks/base/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationInternalUserState.java",
            inputSignatures = "private final @android.annotation.UserIdInt int mUserId\nprivate final @android.annotation.NonNull android.util.ArraySet<java.lang.String> mEnabledHosts\nprivate  boolean mLinkHandlingAllowed\npublic  com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState addHosts(android.util.ArraySet<java.lang.String>)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState addHosts(java.util.Set<java.lang.String>)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState removeHost(java.lang.String)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState removeHosts(android.util.ArraySet<java.lang.String>)\npublic  com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState removeHosts(java.util.Set<java.lang.String>)\nclass DomainVerificationInternalUserState extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genSetters=true, genEqualsHashCode=true, genToString=true, genBuilder=false)")
    @Deprecated
    private void __metadata() {}

Loading