diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationDebug.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationDebug.java index c9067a3a9392e..1c9b8265bdaf6 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationDebug.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationDebug.java @@ -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 allWebDomains = mCollector.collectAllWebDomains(pkg); - SparseArray userStates = + SparseArray 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 reusedSet, - @NonNull ArraySet allWebDomains, boolean wasHeaderPrinted) { + @Nullable DomainVerificationInternalUserState userState, + @NonNull ArraySet reusedSet, @NonNull ArraySet allWebDomains, + boolean wasHeaderPrinted) { reusedSet.clear(); reusedSet.addAll(allWebDomains); if (userState != null) { diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationPersistence.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationPersistence.java index c864b2937f6b0..14e4b41735ef3 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationPersistence.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationPersistence.java @@ -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 stateMap = new ArrayMap<>(); - final SparseArray userStates = new SparseArray<>(); + final SparseArray 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 userStates) { + @NonNull SparseArray 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 states) throws IOException { + @NonNull SparseArray 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()) diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java index 3b25c7a24eba6..4623285eebd6c 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationService.java @@ -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 array = pkgState.getUserSelectionStates(); + SparseArray 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 domains = new ArrayMap<>(webDomainsSize); ArrayMap stateMap = pkgState.getStateMap(); - DomainVerificationUserState userState = pkgState.getUserSelectionState(userId); + DomainVerificationInternalUserState userState = pkgState.getUserSelectionState(userId); Set 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 newStateMap = new ArrayMap<>(); - SparseArray newUserStates = new SparseArray<>(); + SparseArray 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 oldUserStates = + SparseArray 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 oldEnabledHosts = oldUserState.getEnabledHosts(); ArraySet 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) { diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationSettings.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationSettings.java index a8e937cf2b902..5f7e06d08e7ee 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationSettings.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationSettings.java @@ -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 oldSelectionStates = + SparseArray oldSelectionStates = oldState.getUserSelectionStates(); - SparseArray newSelectionStates = + SparseArray newSelectionStates = newState.getUserSelectionStates(); - DomainVerificationUserState newUserState = newSelectionStates.get(UserHandle.USER_SYSTEM); + DomainVerificationInternalUserState newUserState = + newSelectionStates.get(UserHandle.USER_SYSTEM); if (newUserState != null) { ArraySet 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 { diff --git a/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationUserState.java b/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationInternalUserState.java similarity index 74% rename from services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationUserState.java rename to services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationInternalUserState.java index 8fbb33afb6ca5..aa7407ce3fe84 100644 --- a/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationUserState.java +++ b/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationInternalUserState.java @@ -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 newHosts) { + public DomainVerificationInternalUserState addHosts(@NonNull ArraySet newHosts) { mEnabledHosts.addAll(newHosts); return this; } - public DomainVerificationUserState addHosts(@NonNull Set newHosts) { + public DomainVerificationInternalUserState addHosts(@NonNull Set 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 newHosts) { + public DomainVerificationInternalUserState removeHosts(@NonNull ArraySet newHosts) { mEnabledHosts.removeAll(newHosts); return this; } - public DomainVerificationUserState removeHosts(@NonNull Set newHosts) { + public DomainVerificationInternalUserState removeHosts(@NonNull Set 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 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 mEnabledHosts\nprivate boolean mLinkHandlingAllowed\npublic com.android.server.pm.verify.domain.models.DomainVerificationUserState addHosts(android.util.ArraySet)\npublic com.android.server.pm.verify.domain.models.DomainVerificationUserState addHosts(java.util.Set)\npublic com.android.server.pm.verify.domain.models.DomainVerificationUserState removeHosts(android.util.ArraySet)\npublic com.android.server.pm.verify.domain.models.DomainVerificationUserState removeHosts(java.util.Set)\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 mEnabledHosts\nprivate boolean mLinkHandlingAllowed\npublic com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState addHosts(android.util.ArraySet)\npublic com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState addHosts(java.util.Set)\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)\npublic com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState removeHosts(java.util.Set)\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() {} diff --git a/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationPkgState.java b/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationPkgState.java index 48099aa5382bb..d3e6070ad4c7f 100644 --- a/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationPkgState.java +++ b/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationPkgState.java @@ -44,8 +44,8 @@ public class DomainVerificationPkgState { /** * Whether or not the package declares any autoVerify domains. This is separate from an empty - * check on the map itself, because an empty map means no response recorded, not necessarily no - * domains declared. When this is false, {@link #mStateMap} will be empty, but + * check on the map itself, because an empty map means no response recorded, not necessarily + * no domains declared. When this is false, {@link #mStateMap} will be empty, but * {@link #mUserSelectionStates} may contain any domains the user has explicitly chosen to * allow this package to open, which may or may not be marked autoVerify. */ @@ -62,7 +62,7 @@ public class DomainVerificationPkgState { private final ArrayMap mStateMap; @NonNull - private final SparseArray mUserSelectionStates; + private final SparseArray mUserSelectionStates; public DomainVerificationPkgState(@NonNull String packageName, @NonNull UUID id, boolean hasAutoVerifyDomains) { @@ -70,15 +70,16 @@ public class DomainVerificationPkgState { } @Nullable - public DomainVerificationUserState getUserSelectionState(@UserIdInt int userId) { + public DomainVerificationInternalUserState getUserSelectionState(@UserIdInt int userId) { return mUserSelectionStates.get(userId); } @Nullable - public DomainVerificationUserState getOrCreateUserSelectionState(@UserIdInt int userId) { - DomainVerificationUserState userState = mUserSelectionStates.get(userId); + public DomainVerificationInternalUserState getOrCreateUserSelectionState( + @UserIdInt int userId) { + DomainVerificationInternalUserState userState = mUserSelectionStates.get(userId); if (userState == null) { - userState = new DomainVerificationUserState(userId); + userState = new DomainVerificationInternalUserState(userId); mUserSelectionStates.put(userId, userState); } return userState; @@ -101,7 +102,7 @@ public class DomainVerificationPkgState { } private boolean userSelectionStatesEquals( - @NonNull SparseArray other) { + @NonNull SparseArray other) { return mUserSelectionStates.contentEquals(other); } @@ -113,7 +114,7 @@ public class DomainVerificationPkgState { // CHECKSTYLE:OFF Generated code // // To regenerate run: - // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/domain/verify/models/DomainVerificationPkgState.java + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationPkgState.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control @@ -123,9 +124,15 @@ public class DomainVerificationPkgState { /** * Creates a new DomainVerificationPkgState. * + * @param hasAutoVerifyDomains + * Whether or not the package declares any autoVerify domains. This is separate from an empty + * check on the map itself, because an empty map means no response recorded, not necessarily + * no domains declared. When this is false, {@link #mStateMap} will be empty, but + * {@link #mUserSelectionStates} may contain any domains the user has explicitly chosen to + * allow this package to open, which may or may not be marked autoVerify. * @param stateMap * Map of domains to state integers. Only domains that are not set to the default value of - * {@link DomainVerificationManager#STATE_NO_RESPONSE} are included. + * {@link DomainVerificationState#STATE_NO_RESPONSE} are included. * * TODO(b/159952358): Hide the state map entirely from the caller, to allow optimizations, * such as storing no state when the package is marked as a linked app in SystemConfig. @@ -136,7 +143,7 @@ public class DomainVerificationPkgState { @NonNull UUID id, boolean hasAutoVerifyDomains, @NonNull ArrayMap stateMap, - @NonNull SparseArray userSelectionStates) { + @NonNull SparseArray userSelectionStates) { this.mPackageName = packageName; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mPackageName); @@ -164,6 +171,13 @@ public class DomainVerificationPkgState { return mId; } + /** + * Whether or not the package declares any autoVerify domains. This is separate from an empty + * check on the map itself, because an empty map means no response recorded, not necessarily + * no domains declared. When this is false, {@link #mStateMap} will be empty, but + * {@link #mUserSelectionStates} may contain any domains the user has explicitly chosen to + * allow this package to open, which may or may not be marked autoVerify. + */ @DataClass.Generated.Member public boolean isHasAutoVerifyDomains() { return mHasAutoVerifyDomains; @@ -171,7 +185,7 @@ public class DomainVerificationPkgState { /** * Map of domains to state integers. Only domains that are not set to the default value of - * {@link DomainVerificationManager#STATE_NO_RESPONSE} are included. + * {@link DomainVerificationState#STATE_NO_RESPONSE} are included. * * TODO(b/159952358): Hide the state map entirely from the caller, to allow optimizations, * such as storing no state when the package is marked as a linked app in SystemConfig. @@ -182,7 +196,7 @@ public class DomainVerificationPkgState { } @DataClass.Generated.Member - public @NonNull SparseArray getUserSelectionStates() { + public @NonNull SparseArray getUserSelectionStates() { return mUserSelectionStates; } @@ -237,10 +251,10 @@ public class DomainVerificationPkgState { } @DataClass.Generated( - time = 1608234185474L, + time = 1614818241707L, codegenVersion = "1.0.22", - sourceFile = "frameworks/base/services/core/java/com/android/server/pm/domain/verify/models/DomainVerificationPkgState.java", - inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate @android.annotation.NonNull java.util.UUID mId\nprivate final boolean mHasAutoVerifyDomains\nprivate final @android.annotation.NonNull android.util.ArrayMap mStateMap\nprivate final @android.annotation.NonNull android.util.SparseArray mUserSelectionStates\npublic @android.annotation.Nullable com.android.server.pm.verify.domain.models.DomainVerificationUserState getUserSelectionState(int)\npublic @android.annotation.Nullable com.android.server.pm.verify.domain.models.DomainVerificationUserState getOrCreateUserSelectionState(int)\npublic void setId(java.util.UUID)\npublic void removeUser(int)\npublic void removeAllUsers()\nprivate int userSelectionStatesHashCode()\nprivate boolean userSelectionStatesEquals(android.util.SparseArray)\nclass DomainVerificationPkgState extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)") + sourceFile = "frameworks/base/services/core/java/com/android/server/pm/verify/domain/models/DomainVerificationPkgState.java", + inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate @android.annotation.NonNull java.util.UUID mId\nprivate final boolean mHasAutoVerifyDomains\nprivate final @android.annotation.NonNull android.util.ArrayMap mStateMap\nprivate final @android.annotation.NonNull android.util.SparseArray mUserSelectionStates\npublic @android.annotation.Nullable com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState getUserSelectionState(int)\npublic @android.annotation.Nullable com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState getOrCreateUserSelectionState(int)\npublic void setId(java.util.UUID)\npublic void removeUser(int)\npublic void removeAllUsers()\nprivate int userSelectionStatesHashCode()\nprivate boolean userSelectionStatesEquals(android.util.SparseArray)\nclass DomainVerificationPkgState extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)") @Deprecated private void __metadata() {} diff --git a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationPersistenceTest.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationPersistenceTest.kt index a92ab9e35ddca..98cf530b7bc8f 100644 --- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationPersistenceTest.kt +++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationPersistenceTest.kt @@ -22,9 +22,9 @@ import android.util.TypedXmlPullParser import android.util.TypedXmlSerializer import android.util.Xml import com.android.server.pm.verify.domain.DomainVerificationPersistence +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.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage import org.junit.Rule @@ -102,14 +102,14 @@ class DomainVerificationPersistenceTest { // A domain without a written state falls back to default stateMap["missing-state.com"] = DomainVerificationManager.STATE_NO_RESPONSE - userSelectionStates[1] = DomainVerificationUserState(1).apply { + userSelectionStates[1] = DomainVerificationInternalUserState(1).apply { addHosts(setOf("example-user1.com", "example-user1.org")) isLinkHandlingAllowed = true } } val stateOne = mockEmptyPkgState(1).apply { // It's valid to have a user selection without any autoVerify domains - userSelectionStates[1] = DomainVerificationUserState(1).apply { + userSelectionStates[1] = DomainVerificationInternalUserState(1).apply { addHosts(setOf("example-user1.com", "example-user1.org")) isLinkHandlingAllowed = false } @@ -214,7 +214,7 @@ class DomainVerificationPersistenceTest { private fun mockPkgState(id: Int) = mockEmptyPkgState(id).apply { stateMap["$packageName.com"] = id - userSelectionStates[id] = DomainVerificationUserState(id).apply { + userSelectionStates[id] = DomainVerificationInternalUserState(id).apply { addHosts(setOf("$packageName-user.com")) isLinkHandlingAllowed = true }