From 0af5b335ab624b5233ffba744bc9506b6adb8b83 Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 2 Mar 2021 15:28:57 -0800 Subject: [PATCH] Rename to DomainVerificationUserState Better reflects the fact that the map no longer contains only the selection state, but the domain state in general for the user. Bug: 181637637 Test: none, naming refactor Change-Id: I28bc73906f764d83c258fa10e23f2821e9482419 --- core/api/current.txt | 6 +-- core/api/system-current.txt | 2 +- .../android/content/pm/PackageManager.java | 2 +- .../content/pm/verify/domain/DomainOwner.java | 26 ++-------- .../verify/domain/DomainVerificationInfo.java | 7 ++- .../domain/DomainVerificationManager.java | 8 +-- ....aidl => DomainVerificationUserState.aidl} | 2 +- ....java => DomainVerificationUserState.java} | 37 +++++++------- .../domain/IDomainVerificationManager.aidl | 4 +- .../domain/DomainVerificationDebug.java | 4 +- .../domain/DomainVerificationEnforcer.java | 2 +- .../domain/DomainVerificationManagerStub.java | 6 +-- .../domain/DomainVerificationPersistence.java | 2 +- .../domain/DomainVerificationService.java | 47 +++++++++-------- .../domain/DomainVerificationSettings.java | 4 +- .../domain/DomainVerificationShell.java | 16 +++--- .../models/DomainVerificationPkgState.java | 51 +++++++++---------- .../domain/DomainVerificationCoreApiTest.kt | 19 ++++--- .../domain/DomainVerificationEnforcerTest.kt | 38 +++++++------- .../DomainVerificationModelExtensions.kt | 12 ++--- .../DomainVerificationPersistenceTest.kt | 6 +-- .../DomainVerificationSettingsMutationTest.kt | 8 +-- ...inVerificationUserSelectionOverrideTest.kt | 14 ++--- 23 files changed, 151 insertions(+), 172 deletions(-) rename core/java/android/content/pm/verify/domain/{DomainVerificationUserSelection.aidl => DomainVerificationUserState.aidl} (93%) rename core/java/android/content/pm/verify/domain/{DomainVerificationUserSelection.java => DomainVerificationUserState.java} (91%) diff --git a/core/api/current.txt b/core/api/current.txt index 8ce2d5d0da05d..7085cb4f7322f 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12950,17 +12950,17 @@ package android.content.pm { package android.content.pm.verify.domain { public final class DomainVerificationManager { - method @Nullable public android.content.pm.verify.domain.DomainVerificationUserSelection getDomainVerificationUserSelection(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException; + method @Nullable public android.content.pm.verify.domain.DomainVerificationUserState getDomainVerificationUserState(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException; } - public final class DomainVerificationUserSelection implements android.os.Parcelable { + public final class DomainVerificationUserState implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.Map getHostToStateMap(); method @NonNull public String getPackageName(); method @NonNull public android.os.UserHandle getUser(); method @NonNull public boolean isLinkHandlingAllowed(); method public void writeToParcel(@NonNull android.os.Parcel, int); - field @NonNull public static final android.os.Parcelable.Creator CREATOR; + field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int DOMAIN_STATE_NONE = 0; // 0x0 field public static final int DOMAIN_STATE_SELECTED = 1; // 0x1 field public static final int DOMAIN_STATE_VERIFIED = 2; // 0x2 diff --git a/core/api/system-current.txt b/core/api/system-current.txt index af16151d5e7b4..933cfbb059054 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -2791,7 +2791,7 @@ package android.content.pm.verify.domain { field @NonNull public static final android.os.Parcelable.Creator CREATOR; } - public final class DomainVerificationUserSelection implements android.os.Parcelable { + public final class DomainVerificationUserState implements android.os.Parcelable { method @NonNull public java.util.UUID getIdentifier(); } diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java index 3bc61444f1d1e..fc3539e9540f7 100644 --- a/core/java/android/content/pm/PackageManager.java +++ b/core/java/android/content/pm/PackageManager.java @@ -7029,7 +7029,7 @@ public abstract class PackageManager { * domain to an application, use * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean)}, * passing in all of the domains returned inside - * {@link DomainVerificationManager#getDomainVerificationUserSelection(String)}. + * {@link DomainVerificationManager#getDomainVerificationUserState(String)}. * * @hide */ diff --git a/core/java/android/content/pm/verify/domain/DomainOwner.java b/core/java/android/content/pm/verify/domain/DomainOwner.java index b050f5da79286..5bf2c0983a9a8 100644 --- a/core/java/android/content/pm/verify/domain/DomainOwner.java +++ b/core/java/android/content/pm/verify/domain/DomainOwner.java @@ -66,16 +66,7 @@ public final class DomainOwner implements Parcelable { * @param packageName * Package name of that owns the domain. * @param overrideable - * Whether or not this owner can be automatically overridden. If all owners for a domain are - * overrideable, then calling - * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, - * Set, boolean)} to enable the domain will disable all other owners. On the other hand, if any - * of the owners are non-overrideable, then - * {@link DomainVerificationManager#setDomainVerificationLinkHandlingAllowed(String, - * boolean)} must be called with false to disable all of the other owners before this domain can - * be taken by a new owner through - * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, - * Set, boolean)}. + * Whether or not this owner can be automatically overridden. */ @DataClass.Generated.Member public DomainOwner( @@ -98,16 +89,9 @@ public final class DomainOwner implements Parcelable { } /** - * Whether or not this owner can be automatically overridden. If all owners for a domain are - * overrideable, then calling - * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, - * Set, boolean)} to enable the domain will disable all other owners. On the other hand, if any - * of the owners are non-overrideable, then - * {@link DomainVerificationManager#setDomainVerificationLinkHandlingAllowed(String, - * boolean)} must be called with false to disable all of the other owners before this domain can - * be taken by a new owner through - * {@link DomainVerificationManager#setDomainVerificationUserSelection(UUID, - * Set, boolean)}. + * Whether or not this owner can be automatically overridden. + * + * @see DomainVerificationManager#setDomainVerificationUserSelection(UUID, Set, boolean) */ @DataClass.Generated.Member public boolean isOverrideable() { @@ -205,7 +189,7 @@ public final class DomainOwner implements Parcelable { }; @DataClass.Generated( - time = 1614119379978L, + time = 1614721802044L, codegenVersion = "1.0.22", sourceFile = "frameworks/base/core/java/android/content/pm/verify/domain/DomainOwner.java", inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate final boolean mOverrideable\nclass DomainOwner extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genParcelable=true, genEqualsHashCode=true, genAidl=true, genToString=true)") diff --git a/core/java/android/content/pm/verify/domain/DomainVerificationInfo.java b/core/java/android/content/pm/verify/domain/DomainVerificationInfo.java index 809587524f586..7c335b1d26dda 100644 --- a/core/java/android/content/pm/verify/domain/DomainVerificationInfo.java +++ b/core/java/android/content/pm/verify/domain/DomainVerificationInfo.java @@ -94,7 +94,7 @@ public final class DomainVerificationInfo implements Parcelable { private Map unparcelHostToStateMap(Parcel in) { return DomainVerificationUtils.readHostMap(in, new ArrayMap<>(), - DomainVerificationUserSelection.class.getClassLoader()); + DomainVerificationUserState.class.getClassLoader()); } @@ -105,8 +105,7 @@ public final class DomainVerificationInfo implements Parcelable { // CHECKSTYLE:OFF Generated code // // To regenerate run: - // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/verify/domain - // /DomainVerificationInfo.java + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/verify/domain/DomainVerificationInfo.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control @@ -321,7 +320,7 @@ public final class DomainVerificationInfo implements Parcelable { }; @DataClass.Generated( - time = 1613002530369L, + time = 1614721812023L, codegenVersion = "1.0.22", sourceFile = "frameworks/base/core/java/android/content/pm/verify/domain/DomainVerificationInfo.java", inputSignatures = "private final @android.annotation.NonNull @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForUUID.class) java.util.UUID mIdentifier\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.NonNull java.util.Map mHostToStateMap\nprivate void parcelHostToStateMap(android.os.Parcel,int)\nprivate java.util.Map unparcelHostToStateMap(android.os.Parcel)\nclass DomainVerificationInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=true, genHiddenConstructor=true, genParcelable=true, genToString=true, genEqualsHashCode=true)") diff --git a/core/java/android/content/pm/verify/domain/DomainVerificationManager.java b/core/java/android/content/pm/verify/domain/DomainVerificationManager.java index e18d7a0248623..f7c81bcffda3f 100644 --- a/core/java/android/content/pm/verify/domain/DomainVerificationManager.java +++ b/core/java/android/content/pm/verify/domain/DomainVerificationManager.java @@ -36,7 +36,7 @@ import java.util.UUID; /** * System service to access domain verification APIs. * - * Applications should use {@link #getDomainVerificationUserSelection(String)} if necessary to + * Applications should use {@link #getDomainVerificationUserState(String)} if necessary to * check if/how they are verified for a domain, which is required starting from platform * {@link android.os.Build.VERSION_CODES#S} in order to open {@link Intent}s which declare * {@link Intent#CATEGORY_BROWSABLE} or no category and also match against @@ -222,7 +222,7 @@ public final class DomainVerificationManager { * {@link android.Manifest.permission#UPDATE_DOMAIN_VERIFICATION_USER_SELECTION}) * to update the preferences of the user, when they have chosen to explicitly allow an * application to open links. This is done through querying - * {@link #getDomainVerificationUserSelection(String)} and calling + * {@link #getDomainVerificationUserState(String)} and calling * {@link #setDomainVerificationUserSelection(UUID, Set, boolean)} and * {@link #setDomainVerificationLinkHandlingAllowed(String, boolean)}. * @@ -408,10 +408,10 @@ public final class DomainVerificationManager { * null if the package does not declare any HTTP/HTTPS domains. */ @Nullable - public DomainVerificationUserSelection getDomainVerificationUserSelection( + public DomainVerificationUserState getDomainVerificationUserState( @NonNull String packageName) throws NameNotFoundException { try { - return mDomainVerificationManager.getDomainVerificationUserSelection(packageName, + return mDomainVerificationManager.getDomainVerificationUserState(packageName, mContext.getUserId()); } catch (Exception e) { Exception converted = rethrow(e, packageName); diff --git a/core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.aidl b/core/java/android/content/pm/verify/domain/DomainVerificationUserState.aidl similarity index 93% rename from core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.aidl rename to core/java/android/content/pm/verify/domain/DomainVerificationUserState.aidl index ddb5ef85382a1..94690c1dae938 100644 --- a/core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.aidl +++ b/core/java/android/content/pm/verify/domain/DomainVerificationUserState.aidl @@ -16,4 +16,4 @@ package android.content.pm.verify.domain; -parcelable DomainVerificationUserSelection; +parcelable DomainVerificationUserState; diff --git a/core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.java b/core/java/android/content/pm/verify/domain/DomainVerificationUserState.java similarity index 91% rename from core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.java rename to core/java/android/content/pm/verify/domain/DomainVerificationUserState.java index 8b7f1467a0cb4..1e60abb300119 100644 --- a/core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.java +++ b/core/java/android/content/pm/verify/domain/DomainVerificationUserState.java @@ -30,7 +30,6 @@ import com.android.internal.util.DataClass; import com.android.internal.util.Parcelling; import java.util.Map; -import java.util.Set; import java.util.UUID; /** @@ -60,7 +59,7 @@ import java.util.UUID; @SuppressWarnings("DefaultAnnotationParam") @DataClass(genAidl = true, genHiddenConstructor = true, genParcelable = true, genToString = true, genEqualsHashCode = true, genHiddenConstDefs = true) -public final class DomainVerificationUserSelection implements Parcelable { +public final class DomainVerificationUserState implements Parcelable { /** * The domain is unverified and unselected, and the application is unable to open web links @@ -117,7 +116,7 @@ public final class DomainVerificationUserSelection implements Parcelable { @NonNull private Map unparcelHostToStateMap(Parcel in) { return DomainVerificationUtils.readHostMap(in, new ArrayMap<>(), - DomainVerificationUserSelection.class.getClassLoader()); + DomainVerificationUserState.class.getClassLoader()); } /** @@ -137,7 +136,7 @@ public final class DomainVerificationUserSelection implements Parcelable { // CHECKSTYLE:OFF Generated code // // To regenerate run: - // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.java + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/verify/domain/DomainVerificationUserState.java // // To exclude the generated code from IntelliJ auto-formatting enable (one-time): // Settings > Editor > Code Style > Formatter Control @@ -169,7 +168,7 @@ public final class DomainVerificationUserSelection implements Parcelable { } /** - * Creates a new DomainVerificationUserSelection. + * Creates a new DomainVerificationUserState. * * @param packageName * The package name that this data corresponds to. @@ -182,7 +181,7 @@ public final class DomainVerificationUserSelection implements Parcelable { * @hide */ @DataClass.Generated.Member - public DomainVerificationUserSelection( + public DomainVerificationUserState( @NonNull UUID identifier, @NonNull String packageName, @NonNull UserHandle user, @@ -245,7 +244,7 @@ public final class DomainVerificationUserSelection implements Parcelable { // You can override field toString logic by defining methods like: // String fieldNameToString() { ... } - return "DomainVerificationUserSelection { " + + return "DomainVerificationUserState { " + "identifier = " + mIdentifier + ", " + "packageName = " + mPackageName + ", " + "user = " + mUser + ", " + @@ -258,13 +257,13 @@ public final class DomainVerificationUserSelection implements Parcelable { @DataClass.Generated.Member public boolean equals(@Nullable Object o) { // You can override field equality logic by defining either of the methods like: - // boolean fieldNameEquals(DomainVerificationUserSelection other) { ... } + // boolean fieldNameEquals(DomainVerificationUserState other) { ... } // boolean fieldNameEquals(FieldType otherValue) { ... } if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; @SuppressWarnings("unchecked") - DomainVerificationUserSelection that = (DomainVerificationUserSelection) o; + DomainVerificationUserState that = (DomainVerificationUserState) o; //noinspection PointlessBooleanExpression return true && java.util.Objects.equals(mIdentifier, that.mIdentifier) @@ -322,7 +321,7 @@ public final class DomainVerificationUserSelection implements Parcelable { /** @hide */ @SuppressWarnings({"unchecked", "RedundantCast"}) @DataClass.Generated.Member - /* package-private */ DomainVerificationUserSelection(@NonNull Parcel in) { + /* package-private */ DomainVerificationUserState(@NonNull Parcel in) { // You can override field unparcelling by defining methods like: // static FieldType unparcelFieldName(Parcel in) { ... } @@ -353,24 +352,24 @@ public final class DomainVerificationUserSelection implements Parcelable { } @DataClass.Generated.Member - public static final @NonNull Parcelable.Creator CREATOR - = new Parcelable.Creator() { + public static final @NonNull Parcelable.Creator CREATOR + = new Parcelable.Creator() { @Override - public DomainVerificationUserSelection[] newArray(int size) { - return new DomainVerificationUserSelection[size]; + public DomainVerificationUserState[] newArray(int size) { + return new DomainVerificationUserState[size]; } @Override - public DomainVerificationUserSelection createFromParcel(@NonNull Parcel in) { - return new DomainVerificationUserSelection(in); + public DomainVerificationUserState createFromParcel(@NonNull Parcel in) { + return new DomainVerificationUserState(in); } }; @DataClass.Generated( - time = 1614649708937L, + time = 1614721840152L, codegenVersion = "1.0.22", - sourceFile = "frameworks/base/core/java/android/content/pm/verify/domain/DomainVerificationUserSelection.java", - inputSignatures = "public static final int DOMAIN_STATE_NONE\npublic static final int DOMAIN_STATE_SELECTED\npublic static final int DOMAIN_STATE_VERIFIED\nprivate final @android.annotation.NonNull @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForUUID.class) java.util.UUID mIdentifier\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.NonNull android.os.UserHandle mUser\nprivate final @android.annotation.NonNull boolean mLinkHandlingAllowed\nprivate final @android.annotation.NonNull java.util.Map mHostToStateMap\nprivate void parcelHostToStateMap(android.os.Parcel,int)\nprivate @android.annotation.NonNull java.util.Map unparcelHostToStateMap(android.os.Parcel)\npublic @android.annotation.SystemApi @android.annotation.NonNull java.util.UUID getIdentifier()\nclass DomainVerificationUserSelection extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=true, genHiddenConstructor=true, genParcelable=true, genToString=true, genEqualsHashCode=true, genHiddenConstDefs=true)") + sourceFile = "frameworks/base/core/java/android/content/pm/verify/domain/DomainVerificationUserState.java", + inputSignatures = "public static final int DOMAIN_STATE_NONE\npublic static final int DOMAIN_STATE_SELECTED\npublic static final int DOMAIN_STATE_VERIFIED\nprivate final @android.annotation.NonNull @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForUUID.class) java.util.UUID mIdentifier\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.NonNull android.os.UserHandle mUser\nprivate final @android.annotation.NonNull boolean mLinkHandlingAllowed\nprivate final @android.annotation.NonNull java.util.Map mHostToStateMap\nprivate void parcelHostToStateMap(android.os.Parcel,int)\nprivate @android.annotation.NonNull java.util.Map unparcelHostToStateMap(android.os.Parcel)\npublic @android.annotation.SystemApi @android.annotation.NonNull java.util.UUID getIdentifier()\nclass DomainVerificationUserState extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=true, genHiddenConstructor=true, genParcelable=true, genToString=true, genEqualsHashCode=true, genHiddenConstDefs=true)") @Deprecated private void __metadata() {} diff --git a/core/java/android/content/pm/verify/domain/IDomainVerificationManager.aidl b/core/java/android/content/pm/verify/domain/IDomainVerificationManager.aidl index 85ad47cd3509e..332b925445813 100644 --- a/core/java/android/content/pm/verify/domain/IDomainVerificationManager.aidl +++ b/core/java/android/content/pm/verify/domain/IDomainVerificationManager.aidl @@ -19,7 +19,7 @@ package android.content.pm.verify.domain; import android.content.pm.verify.domain.DomainOwner; import android.content.pm.verify.domain.DomainSet; import android.content.pm.verify.domain.DomainVerificationInfo; -import android.content.pm.verify.domain.DomainVerificationUserSelection; +import android.content.pm.verify.domain.DomainVerificationUserState; import java.util.List; /** @@ -34,7 +34,7 @@ interface IDomainVerificationManager { DomainVerificationInfo getDomainVerificationInfo(String packageName); @nullable - DomainVerificationUserSelection getDomainVerificationUserSelection(String packageName, + DomainVerificationUserState getDomainVerificationUserState(String packageName, int userId); @nullable 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 1c9b8265bdaf6..b61fd8d633f61 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 @@ -33,9 +33,9 @@ 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.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.DomainVerificationInternalUserState; import java.util.Arrays; import java.util.function.Function; @@ -170,7 +170,7 @@ public class DomainVerificationDebug { ArraySet allWebDomains = mCollector.collectAllWebDomains(pkg); SparseArray userStates = - pkgState.getUserSelectionStates(); + pkgState.getUserStates(); if (userId == UserHandle.USER_ALL) { int size = userStates.size(); if (size == 0) { diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationEnforcer.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationEnforcer.java index 712ed6c19152a..1721a18f4f604 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationEnforcer.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationEnforcer.java @@ -132,7 +132,7 @@ public class DomainVerificationEnforcer { /** * Enforced when mutating user selection state inside an exposed API method. */ - public boolean assertApprovedUserSelectionQuerent(int callingUid, @UserIdInt int callingUserId, + public boolean assertApprovedUserStateQuerent(int callingUid, @UserIdInt int callingUserId, @NonNull String packageName, @UserIdInt int targetUserId) throws SecurityException { if (callingUserId != targetUserId) { mContext.enforcePermission( diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationManagerStub.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationManagerStub.java index d89fe68c05443..a7a52e0cd10c4 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationManagerStub.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationManagerStub.java @@ -25,7 +25,7 @@ import android.content.pm.verify.domain.DomainSet; import android.content.pm.verify.domain.DomainVerificationInfo; import android.content.pm.verify.domain.DomainVerificationManager; import android.content.pm.verify.domain.DomainVerificationManager.InvalidDomainSetException; -import android.content.pm.verify.domain.DomainVerificationUserSelection; +import android.content.pm.verify.domain.DomainVerificationUserState; import android.content.pm.verify.domain.IDomainVerificationManager; import android.os.ServiceSpecificException; @@ -95,10 +95,10 @@ public class DomainVerificationManagerStub extends IDomainVerificationManager.St @Nullable @Override - public DomainVerificationUserSelection getDomainVerificationUserSelection( + public DomainVerificationUserState getDomainVerificationUserState( String packageName, @UserIdInt int userId) { try { - return mService.getDomainVerificationUserSelection(packageName, userId); + return mService.getDomainVerificationUserState(packageName, userId); } catch (Exception e) { throw rethrow(e); } 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 14e4b41735ef3..abb8d2fb6e1e4 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 @@ -205,7 +205,7 @@ public class DomainVerificationPersistence { .attribute(ATTR_HAS_AUTO_VERIFY_DOMAINS, pkgState.isHasAutoVerifyDomains())) { writeStateMap(parentSection, pkgState.getStateMap()); - writeUserStates(parentSection, pkgState.getUserSelectionStates()); + writeUserStates(parentSection, pkgState.getUserStates()); } } 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 4623285eebd6c..e85bbe41f7479 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 @@ -36,7 +36,7 @@ import android.content.pm.verify.domain.DomainVerificationInfo; import android.content.pm.verify.domain.DomainVerificationManager; import android.content.pm.verify.domain.DomainVerificationManager.InvalidDomainSetException; import android.content.pm.verify.domain.DomainVerificationState; -import android.content.pm.verify.domain.DomainVerificationUserSelection; +import android.content.pm.verify.domain.DomainVerificationUserState; import android.content.pm.verify.domain.IDomainVerificationManager; import android.os.UserHandle; import android.util.ArrayMap; @@ -313,7 +313,7 @@ public class DomainVerificationService extends SystemService int size = verifiedDomains.size(); for (int index = 0; index < size; index++) { - removeUserSelectionsForDomain(verifiedDomains.get(index)); + removeUserStatesForDomain(verifiedDomains.get(index)); } } @@ -400,13 +400,12 @@ public class DomainVerificationService extends SystemService } } - private void removeUserSelectionsForDomain(@NonNull String domain) { + private void removeUserStatesForDomain(@NonNull String domain) { synchronized (mLock) { final int size = mAttachedPkgStates.size(); for (int index = 0; index < size; index++) { DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(index); - SparseArray array = - pkgState.getUserSelectionStates(); + SparseArray array = pkgState.getUserStates(); int arraySize = array.size(); for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { array.valueAt(arrayIndex).removeHost(domain); @@ -427,7 +426,7 @@ public class DomainVerificationService extends SystemService throw DomainVerificationUtils.throwPackageUnavailable(packageName); } - pkgState.getOrCreateUserSelectionState(userId) + pkgState.getOrCreateUserState(userId) .setLinkHandlingAllowed(allowed); } @@ -445,11 +444,11 @@ public class DomainVerificationService extends SystemService DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(pkgStateIndex); if (userId == UserHandle.USER_ALL) { for (int aUserId : mConnection.getAllUserIds()) { - pkgState.getOrCreateUserSelectionState(aUserId) + pkgState.getOrCreateUserState(aUserId) .setLinkHandlingAllowed(allowed); } } else { - pkgState.getOrCreateUserSelectionState(userId) + pkgState.getOrCreateUserState(userId) .setLinkHandlingAllowed(allowed); } } @@ -461,7 +460,7 @@ public class DomainVerificationService extends SystemService throw DomainVerificationUtils.throwPackageUnavailable(packageName); } - pkgState.getOrCreateUserSelectionState(userId) + pkgState.getOrCreateUserState(userId) .setLinkHandlingAllowed(allowed); } } @@ -486,7 +485,7 @@ public class DomainVerificationService extends SystemService DomainVerificationPkgState pkgState = getAndValidateAttachedLocked(domainSetId, domains, false /* forAutoVerify */, callingUid, userId); DomainVerificationInternalUserState userState = - pkgState.getOrCreateUserSelectionState(userId); + pkgState.getOrCreateUserState(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. @@ -527,7 +526,7 @@ public class DomainVerificationService extends SystemService } DomainVerificationInternalUserState approvedUserState = - approvedPkgState.getUserSelectionState(userId); + approvedPkgState.getUserState(userId); if (approvedUserState == null) { continue; } @@ -610,7 +609,7 @@ public class DomainVerificationService extends SystemService if (userId == UserHandle.USER_ALL) { for (int aUserId : mConnection.getAllUserIds()) { DomainVerificationInternalUserState userState = - pkgState.getOrCreateUserSelectionState(aUserId); + pkgState.getOrCreateUserState(aUserId); if (enabled) { userState.addHosts(domains); } else { @@ -619,7 +618,7 @@ public class DomainVerificationService extends SystemService } } else { DomainVerificationInternalUserState userState = - pkgState.getOrCreateUserSelectionState(userId); + pkgState.getOrCreateUserState(userId); if (enabled) { userState.addHosts(domains); } else { @@ -630,9 +629,9 @@ public class DomainVerificationService extends SystemService @Nullable @Override - public DomainVerificationUserSelection getDomainVerificationUserSelection( + public DomainVerificationUserState getDomainVerificationUserState( @NonNull String packageName, @UserIdInt int userId) throws NameNotFoundException { - if (!mEnforcer.assertApprovedUserSelectionQuerent(mConnection.getCallingUid(), + if (!mEnforcer.assertApprovedUserStateQuerent(mConnection.getCallingUid(), mConnection.getCallingUserId(), packageName, userId)) { throw DomainVerificationUtils.throwPackageUnavailable(packageName); } @@ -652,7 +651,7 @@ public class DomainVerificationService extends SystemService Map domains = new ArrayMap<>(webDomainsSize); ArrayMap stateMap = pkgState.getStateMap(); - DomainVerificationInternalUserState userState = pkgState.getUserSelectionState(userId); + DomainVerificationInternalUserState userState = pkgState.getUserState(userId); Set enabledHosts = userState == null ? emptySet() : userState.getEnabledHosts(); for (int index = 0; index < webDomainsSize; index++) { @@ -661,11 +660,11 @@ public class DomainVerificationService extends SystemService int domainState; if (state != null && DomainVerificationManager.isStateVerified(state)) { - domainState = DomainVerificationUserSelection.DOMAIN_STATE_VERIFIED; + domainState = DomainVerificationUserState.DOMAIN_STATE_VERIFIED; } else if (enabledHosts.contains(host)) { - domainState = DomainVerificationUserSelection.DOMAIN_STATE_SELECTED; + domainState = DomainVerificationUserState.DOMAIN_STATE_SELECTED; } else { - domainState = DomainVerificationUserSelection.DOMAIN_STATE_NONE; + domainState = DomainVerificationUserState.DOMAIN_STATE_NONE; } domains.put(host, domainState); @@ -673,7 +672,7 @@ public class DomainVerificationService extends SystemService boolean linkHandlingAllowed = userState == null || userState.isLinkHandlingAllowed(); - return new DomainVerificationUserSelection(pkgState.getId(), packageName, + return new DomainVerificationUserState(pkgState.getId(), packageName, UserHandle.of(userId), linkHandlingAllowed, domains); } } @@ -812,7 +811,7 @@ public class DomainVerificationService extends SystemService } SparseArray oldUserStates = - oldPkgState.getUserSelectionStates(); + oldPkgState.getUserStates(); int oldUserStatesSize = oldUserStates.size(); if (oldUserStatesSize > 0) { ArraySet newWebDomains = mCollector.collectValidAutoVerifyDomains(newPkg); @@ -900,7 +899,7 @@ public class DomainVerificationService extends SystemService webDomains = mCollector.collectAllWebDomains(pkg); } - pkgState.getOrCreateUserSelectionState(userId).addHosts(webDomains); + pkgState.getOrCreateUserState(userId).addHosts(webDomains); } } @@ -1269,7 +1268,7 @@ public class DomainVerificationService extends SystemService } @Override - public void clearUserSelections(@Nullable List packageNames, @UserIdInt int userId) { + public void clearUserStates(@Nullable List packageNames, @UserIdInt int userId) { mEnforcer.assertInternal(mConnection.getCallingUid()); synchronized (mLock) { if (packageNames == null) { @@ -1519,7 +1518,7 @@ public class DomainVerificationService extends SystemService return APPROVAL_LEVEL_NONE; } - DomainVerificationInternalUserState userState = pkgState.getUserSelectionState(userId); + DomainVerificationInternalUserState userState = pkgState.getUserState(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 5f7e06d08e7ee..f3d1dbb1f6ada 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 @@ -217,10 +217,10 @@ class DomainVerificationSettings { } SparseArray oldSelectionStates = - oldState.getUserSelectionStates(); + oldState.getUserStates(); SparseArray newSelectionStates = - newState.getUserSelectionStates(); + newState.getUserStates(); DomainVerificationInternalUserState newUserState = newSelectionStates.get(UserHandle.USER_SYSTEM); diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationShell.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationShell.java index d083d11cb2e29..94767f555574c 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationShell.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationShell.java @@ -24,7 +24,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.verify.domain.DomainVerificationManager; import android.content.pm.verify.domain.DomainVerificationState; -import android.content.pm.verify.domain.DomainVerificationUserSelection; +import android.content.pm.verify.domain.DomainVerificationUserState; import android.os.Binder; import android.os.UserHandle; import android.text.TextUtils; @@ -118,7 +118,7 @@ public class DomainVerificationShell { case "set-app-links": return runSetAppLinks(commandHandler); case "set-app-links-user-selection": - return runSetAppLinksUserSelection(commandHandler); + return runSetAppLinksUserState(commandHandler); case "set-app-links-allowed": return runSetAppLinksAllowed(commandHandler); } @@ -193,7 +193,7 @@ public class DomainVerificationShell { } // pm set-app-links-user-selection --user [--package ] ... - private boolean runSetAppLinksUserSelection(@NonNull BasicShellCommandHandler commandHandler) { + private boolean runSetAppLinksUserState(@NonNull BasicShellCommandHandler commandHandler) { Integer userId = null; String packageName = null; @@ -224,7 +224,7 @@ public class DomainVerificationShell { return false; } - userId = translateUserId(userId, "runSetAppLinksUserSelection"); + userId = translateUserId(userId, "runSetAppLinksUserState"); String enabledString = commandHandler.getNextArgRequired(); @@ -326,7 +326,7 @@ public class DomainVerificationShell { } if (userId != null) { - mCallback.clearUserSelections(packageNames, userId); + mCallback.clearUserStates(packageNames, userId); } else { mCallback.clearDomainVerificationState(packageNames); } @@ -457,10 +457,10 @@ public class DomainVerificationShell { throws PackageManager.NameNotFoundException; /** - * @see DomainVerificationManager#getDomainVerificationUserSelection(String) + * @see DomainVerificationManager#getDomainVerificationUserState(String) */ @Nullable - DomainVerificationUserSelection getDomainVerificationUserSelection( + DomainVerificationUserState getDomainVerificationUserState( @NonNull String packageName, @UserIdInt int userId) throws PackageManager.NameNotFoundException; @@ -486,7 +486,7 @@ public class DomainVerificationShell { * Reset all the user selections for the given package names, or all package names if null * is provided. */ - void clearUserSelections(@Nullable List packageNames, @UserIdInt int userId); + void clearUserStates(@Nullable List packageNames, @UserIdInt int userId); /** * Broadcast a verification request for the given package names, or all package names if 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 d3e6070ad4c7f..a089a60227352 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 @@ -19,7 +19,6 @@ package com.android.server.pm.verify.domain.models; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; -import android.content.pm.verify.domain.DomainVerificationManager; import android.content.pm.verify.domain.DomainVerificationState; import android.util.ArrayMap; import android.util.SparseArray; @@ -46,7 +45,7 @@ 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 - * {@link #mUserSelectionStates} may contain any domains the user has explicitly chosen to + * {@link #mUserStates} may contain any domains the user has explicitly chosen to * allow this package to open, which may or may not be marked autoVerify. */ private final boolean mHasAutoVerifyDomains; @@ -62,7 +61,7 @@ public class DomainVerificationPkgState { private final ArrayMap mStateMap; @NonNull - private final SparseArray mUserSelectionStates; + private final SparseArray mUserStates; public DomainVerificationPkgState(@NonNull String packageName, @NonNull UUID id, boolean hasAutoVerifyDomains) { @@ -70,17 +69,17 @@ public class DomainVerificationPkgState { } @Nullable - public DomainVerificationInternalUserState getUserSelectionState(@UserIdInt int userId) { - return mUserSelectionStates.get(userId); + public DomainVerificationInternalUserState getUserState(@UserIdInt int userId) { + return mUserStates.get(userId); } @Nullable - public DomainVerificationInternalUserState getOrCreateUserSelectionState( + public DomainVerificationInternalUserState getOrCreateUserState( @UserIdInt int userId) { - DomainVerificationInternalUserState userState = mUserSelectionStates.get(userId); + DomainVerificationInternalUserState userState = mUserStates.get(userId); if (userState == null) { userState = new DomainVerificationInternalUserState(userId); - mUserSelectionStates.put(userId, userState); + mUserStates.put(userId, userState); } return userState; } @@ -90,20 +89,20 @@ public class DomainVerificationPkgState { } public void removeUser(@UserIdInt int userId) { - mUserSelectionStates.remove(userId); + mUserStates.remove(userId); } public void removeAllUsers() { - mUserSelectionStates.clear(); + mUserStates.clear(); } - private int userSelectionStatesHashCode() { - return mUserSelectionStates.contentHashCode(); + private int userStatesHashCode() { + return mUserStates.contentHashCode(); } - private boolean userSelectionStatesEquals( + private boolean userStatesEquals( @NonNull SparseArray other) { - return mUserSelectionStates.contentEquals(other); + return mUserStates.contentEquals(other); } @@ -128,7 +127,7 @@ 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 - * {@link #mUserSelectionStates} may contain any domains the user has explicitly chosen to + * {@link #mUserStates} 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 @@ -143,7 +142,7 @@ public class DomainVerificationPkgState { @NonNull UUID id, boolean hasAutoVerifyDomains, @NonNull ArrayMap stateMap, - @NonNull SparseArray userSelectionStates) { + @NonNull SparseArray userStates) { this.mPackageName = packageName; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mPackageName); @@ -154,9 +153,9 @@ public class DomainVerificationPkgState { this.mStateMap = stateMap; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mStateMap); - this.mUserSelectionStates = userSelectionStates; + this.mUserStates = userStates; com.android.internal.util.AnnotationValidations.validate( - NonNull.class, null, mUserSelectionStates); + NonNull.class, null, mUserStates); // onConstructed(); // You can define this method to get a callback } @@ -175,7 +174,7 @@ 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 - * {@link #mUserSelectionStates} may contain any domains the user has explicitly chosen to + * {@link #mUserStates} 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 @@ -196,8 +195,8 @@ public class DomainVerificationPkgState { } @DataClass.Generated.Member - public @NonNull SparseArray getUserSelectionStates() { - return mUserSelectionStates; + public @NonNull SparseArray getUserStates() { + return mUserStates; } @Override @@ -211,7 +210,7 @@ public class DomainVerificationPkgState { "id = " + mId + ", " + "hasAutoVerifyDomains = " + mHasAutoVerifyDomains + ", " + "stateMap = " + mStateMap + ", " + - "userSelectionStates = " + mUserSelectionStates + + "userStates = " + mUserStates + " }"; } @@ -232,7 +231,7 @@ public class DomainVerificationPkgState { && Objects.equals(mId, that.mId) && mHasAutoVerifyDomains == that.mHasAutoVerifyDomains && Objects.equals(mStateMap, that.mStateMap) - && userSelectionStatesEquals(that.mUserSelectionStates); + && userStatesEquals(that.mUserStates); } @Override @@ -246,15 +245,15 @@ public class DomainVerificationPkgState { _hash = 31 * _hash + Objects.hashCode(mId); _hash = 31 * _hash + Boolean.hashCode(mHasAutoVerifyDomains); _hash = 31 * _hash + Objects.hashCode(mStateMap); - _hash = 31 * _hash + userSelectionStatesHashCode(); + _hash = 31 * _hash + userStatesHashCode(); return _hash; } @DataClass.Generated( - time = 1614818241707L, + time = 1614818362549L, codegenVersion = "1.0.22", 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)") + 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 mUserStates\npublic @android.annotation.Nullable com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState getUserState(int)\npublic @android.annotation.Nullable com.android.server.pm.verify.domain.models.DomainVerificationInternalUserState getOrCreateUserState(int)\npublic void setId(java.util.UUID)\npublic void removeUser(int)\npublic void removeAllUsers()\nprivate int userStatesHashCode()\nprivate boolean userStatesEquals(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/DomainVerificationCoreApiTest.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationCoreApiTest.kt index 9447f390ada06..8ef92393242a9 100644 --- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationCoreApiTest.kt +++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationCoreApiTest.kt @@ -19,7 +19,7 @@ package com.android.server.pm.test.verify.domain import android.content.pm.verify.domain.DomainSet import android.content.pm.verify.domain.DomainVerificationInfo import android.content.pm.verify.domain.DomainVerificationRequest -import android.content.pm.verify.domain.DomainVerificationUserSelection +import android.content.pm.verify.domain.DomainVerificationUserState import android.os.Parcel import android.os.Parcelable import android.os.UserHandle @@ -28,7 +28,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import java.util.UUID -import kotlin.random.Random @RunWith(Parameterized::class) class DomainVerificationCoreApiTest { @@ -92,9 +91,9 @@ class DomainVerificationCoreApiTest { } ), Parameter( - testName = "DomainVerificationUserSelection", + testName = "DomainVerificationUserState", initial = { - DomainVerificationUserSelection( + DomainVerificationUserState( UUID.fromString("703f6d34-6241-4cfd-8176-2e1d23355811"), "com.test.pkg", UserHandle.of(10), @@ -103,22 +102,22 @@ class DomainVerificationCoreApiTest { .associate { it.value to (it.index % 3) } ) }, - unparcel = { DomainVerificationUserSelection.CREATOR.createFromParcel(it) }, + unparcel = { DomainVerificationUserState.CREATOR.createFromParcel(it) }, assertion = { first, second -> - assertAll(first, second, + assertAll(first, second, { it.identifier }, { it.component1() }, IS_EQUAL_TO ) - assertAll(first, second, + assertAll(first, second, { it.packageName }, { it.component2() }, IS_EQUAL_TO ) - assertAll(first, second, + assertAll(first, second, { it.user }, { it.component3() }, IS_EQUAL_TO ) - assertAll( + assertAll( first, second, { it.isLinkHandlingAllowed }, { it.component4() }, IS_EQUAL_TO ) - assertAll>( + assertAll>( first, second, { it.hostToStateMap }, { it.component5() }, IS_MAP_EQUAL_TO ) diff --git a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationEnforcerTest.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationEnforcerTest.kt index 2616a59c7edba..53f0ca20e787f 100644 --- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationEnforcerTest.kt +++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationEnforcerTest.kt @@ -156,9 +156,9 @@ class DomainVerificationEnforcerTest { }, enforcer( Type.SELECTION_QUERENT, - "approvedUserSelectionQuerent" + "approvedUserStateQuerent" ) { - assertApprovedUserSelectionQuerent( + assertApprovedUserStateQuerent( it.callingUid, it.callingUserId, it.targetPackageName, it.userId ) @@ -179,7 +179,7 @@ class DomainVerificationEnforcerTest { ArraySet(setOf("example.com")) ) }, - service(Type.INTERNAL, "setUserSelectionInternal") { + service(Type.INTERNAL, "setUserStateInternal") { setDomainVerificationUserSelectionInternal( it.userId, it.targetPackageName, @@ -193,8 +193,8 @@ class DomainVerificationEnforcerTest { service(Type.INTERNAL, "clearState") { clearDomainVerificationState(listOf(it.targetPackageName)) }, - service(Type.INTERNAL, "clearUserSelections") { - clearUserSelections(listOf(it.targetPackageName), it.userId) + service(Type.INTERNAL, "clearUserStates") { + clearUserStates(listOf(it.targetPackageName), it.userId) }, service(Type.VERIFIER, "queryValidPackageNames") { queryValidVerificationPackageNames() @@ -220,10 +220,10 @@ class DomainVerificationEnforcerTest { service(Type.SELECTOR_USER, "setLinkHandlingAllowedUserId") { setDomainVerificationLinkHandlingAllowed(it.targetPackageName, true, it.userId) }, - service(Type.SELECTION_QUERENT, "getUserSelectionUserId") { - getDomainVerificationUserSelection(it.targetPackageName, it.userId) + service(Type.SELECTION_QUERENT, "getUserStateUserId") { + getDomainVerificationUserState(it.targetPackageName, it.userId) }, - service(Type.SELECTOR_USER, "setUserSelectionUserId") { + service(Type.SELECTOR_USER, "setUserStateUserId") { setDomainVerificationUserSelection( it.targetDomainSetId, setOf("example.com"), @@ -354,7 +354,7 @@ class DomainVerificationEnforcerTest { Type.INTERNAL -> internal() Type.QUERENT -> approvedQuerent() Type.VERIFIER -> approvedVerifier() - Type.SELECTION_QUERENT -> approvedUserSelectionQuerent(verifyCrossUser = true) + Type.SELECTION_QUERENT -> approvedUserStateQuerent(verifyCrossUser = true) Type.SELECTOR -> approvedUserSelector(verifyCrossUser = false) Type.SELECTOR_USER -> approvedUserSelector(verifyCrossUser = true) Type.LEGACY_QUERENT -> legacyQuerent() @@ -379,12 +379,12 @@ class DomainVerificationEnforcerTest { } private fun approvedQuerent() { - val allowUserSelection = AtomicBoolean(false) + val allowUserState = AtomicBoolean(false) val allowPreferredApps = AtomicBoolean(false) val allowQueryAll = AtomicBoolean(false) val context: Context = mockThrowOnUnmocked { initPermission( - allowUserSelection, + allowUserState, android.Manifest.permission.UPDATE_DOMAIN_VERIFICATION_USER_SELECTION ) initPermission( @@ -411,7 +411,7 @@ class DomainVerificationEnforcerTest { assertFails { runMethod(target, NON_VERIFIER_UID) } - allowUserSelection.set(true) + allowUserState.set(true) assertFails { runMethod(target, NON_VERIFIER_UID) } @@ -462,7 +462,7 @@ class DomainVerificationEnforcerTest { assertFails { runMethod(target, NON_VERIFIER_UID) } } - private fun approvedUserSelectionQuerent(verifyCrossUser: Boolean) { + private fun approvedUserStateQuerent(verifyCrossUser: Boolean) { val allowInteractAcrossUsers = AtomicBoolean(false) val context: Context = mockThrowOnUnmocked { initPermission( @@ -512,11 +512,11 @@ class DomainVerificationEnforcerTest { } private fun approvedUserSelector(verifyCrossUser: Boolean) { - val allowUserSelection = AtomicBoolean(false) + val allowUserState = AtomicBoolean(false) val allowInteractAcrossUsers = AtomicBoolean(false) val context: Context = mockThrowOnUnmocked { initPermission( - allowUserSelection, + allowUserState, android.Manifest.permission.UPDATE_DOMAIN_VERIFICATION_USER_SELECTION ) initPermission( @@ -557,7 +557,7 @@ class DomainVerificationEnforcerTest { runTestCases(callingUserId, notCallingUserId, throws = true) } - allowUserSelection.set(true) + allowUserState.set(true) runTestCases(callingUserId, callingUserId, throws = false) if (verifyCrossUser) { @@ -683,7 +683,7 @@ class DomainVerificationEnforcerTest { private fun ownerQuerent(verifyCrossUser: Boolean) { val allowQueryAll = AtomicBoolean(false) - val allowUserSelection = AtomicBoolean(false) + val allowUserState = AtomicBoolean(false) val allowInteractAcrossUsers = AtomicBoolean(false) val context: Context = mockThrowOnUnmocked { initPermission( @@ -691,7 +691,7 @@ class DomainVerificationEnforcerTest { android.Manifest.permission.QUERY_ALL_PACKAGES ) initPermission( - allowUserSelection, + allowUserState, android.Manifest.permission.UPDATE_DOMAIN_VERIFICATION_USER_SELECTION ) initPermission( @@ -732,7 +732,7 @@ class DomainVerificationEnforcerTest { runTestCases(callingUserId, notCallingUserId, throws = true) } - allowUserSelection.set(true) + allowUserState.set(true) runTestCases(callingUserId, callingUserId, throws = false) if (verifyCrossUser) { diff --git a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationModelExtensions.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationModelExtensions.kt index 439048ce51bb6..8c31c65e1b0a1 100644 --- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationModelExtensions.kt +++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationModelExtensions.kt @@ -18,7 +18,7 @@ package com.android.server.pm.test.verify.domain import android.content.pm.verify.domain.DomainVerificationRequest import android.content.pm.verify.domain.DomainVerificationInfo -import android.content.pm.verify.domain.DomainVerificationUserSelection +import android.content.pm.verify.domain.DomainVerificationUserState import com.android.server.pm.verify.domain.DomainVerificationPersistence operator fun android.util.Pair.component1() = first @@ -30,11 +30,11 @@ operator fun DomainVerificationInfo.component1() = identifier operator fun DomainVerificationInfo.component2() = packageName operator fun DomainVerificationInfo.component3() = hostToStateMap -operator fun DomainVerificationUserSelection.component1() = identifier -operator fun DomainVerificationUserSelection.component2() = packageName -operator fun DomainVerificationUserSelection.component3() = user -operator fun DomainVerificationUserSelection.component4() = isLinkHandlingAllowed -operator fun DomainVerificationUserSelection.component5() = hostToStateMap +operator fun DomainVerificationUserState.component1() = identifier +operator fun DomainVerificationUserState.component2() = packageName +operator fun DomainVerificationUserState.component3() = user +operator fun DomainVerificationUserState.component4() = isLinkHandlingAllowed +operator fun DomainVerificationUserState.component5() = hostToStateMap operator fun DomainVerificationPersistence.ReadResult.component1() = active operator fun DomainVerificationPersistence.ReadResult.component2() = restored 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 98cf530b7bc8f..ad9aa7b6e3ae0 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 @@ -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] = DomainVerificationInternalUserState(1).apply { + userStates[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] = DomainVerificationInternalUserState(1).apply { + userStates[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] = DomainVerificationInternalUserState(id).apply { + userStates[id] = DomainVerificationInternalUserState(id).apply { addHosts(setOf("$packageName-user.com")) isLinkHandlingAllowed = true } diff --git a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationSettingsMutationTest.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationSettingsMutationTest.kt index f52939c3e8992..0d8f275be09c7 100644 --- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationSettingsMutationTest.kt +++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationSettingsMutationTest.kt @@ -122,8 +122,8 @@ class DomainVerificationSettingsMutationTest { service("clearState") { clearDomainVerificationState(listOf(TEST_PKG)) }, - service("clearUserSelections") { - clearUserSelections(listOf(TEST_PKG), TEST_USER_ID) + service("clearUserStates") { + clearUserStates(listOf(TEST_PKG), TEST_USER_ID) }, service("setStatus") { setDomainVerificationStatus( @@ -153,7 +153,7 @@ class DomainVerificationSettingsMutationTest { service("setLinkHandlingAllowedInternal") { setDomainVerificationLinkHandlingAllowedInternal(TEST_PKG, true, TEST_USER_ID) }, - service("setUserSelectionUserId") { + service("setUserStateUserId") { setDomainVerificationUserSelection( TEST_UUID, setOf("example.com"), @@ -161,7 +161,7 @@ class DomainVerificationSettingsMutationTest { TEST_USER_ID ) }, - service("setUserSelectionInternal") { + service("setUserStateInternal") { setDomainVerificationUserSelectionInternal( TEST_USER_ID, TEST_PKG, diff --git a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationUserSelectionOverrideTest.kt b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationUserSelectionOverrideTest.kt index efab85b514956..0576125748fb1 100644 --- a/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationUserSelectionOverrideTest.kt +++ b/services/tests/PackageManagerServiceTests/unit/src/com/android/server/pm/test/verify/domain/DomainVerificationUserSelectionOverrideTest.kt @@ -21,7 +21,7 @@ import android.content.pm.PackageManager import android.content.pm.parsing.component.ParsedActivity import android.content.pm.parsing.component.ParsedIntentInfo import android.content.pm.verify.domain.DomainVerificationManager -import android.content.pm.verify.domain.DomainVerificationUserSelection +import android.content.pm.verify.domain.DomainVerificationUserState import android.os.Build import android.os.PatternMatcher import android.os.Process @@ -39,7 +39,7 @@ import org.mockito.ArgumentMatchers.anyLong import org.mockito.ArgumentMatchers.anyString import java.util.UUID -class DomainVerificationUserSelectionOverrideTest { +class DomainVerificationUserStateOverrideTest { companion object { private const val PKG_ONE = "com.test.one" @@ -48,11 +48,11 @@ class DomainVerificationUserSelectionOverrideTest { private val UUID_TWO = UUID.fromString("a3389c16-7f9f-4e86-85e3-500d1249c74c") private val DOMAIN_ONE = - DomainVerificationUserSelectionOverrideTest::class.java.packageName + DomainVerificationUserStateOverrideTest::class.java.packageName - private const val STATE_NONE = DomainVerificationUserSelection.DOMAIN_STATE_NONE - private const val STATE_SELECTED = DomainVerificationUserSelection.DOMAIN_STATE_SELECTED - private const val STATE_VERIFIED = DomainVerificationUserSelection.DOMAIN_STATE_VERIFIED + private const val STATE_NONE = DomainVerificationUserState.DOMAIN_STATE_NONE + private const val STATE_SELECTED = DomainVerificationUserState.DOMAIN_STATE_SELECTED + private const val STATE_VERIFIED = DomainVerificationUserState.DOMAIN_STATE_VERIFIED private const val USER_ID = 0 } @@ -170,5 +170,5 @@ class DomainVerificationUserSelectionOverrideTest { } private fun DomainVerificationService.stateFor(pkgName: String, host: String) = - getDomainVerificationUserSelection(pkgName, USER_ID)!!.hostToStateMap[host] + getDomainVerificationUserState(pkgName, USER_ID)!!.hostToStateMap[host] }