Merge "Fix preserving app links user selection on package update" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bf3446ce37
@@ -896,7 +896,7 @@ public class DomainVerificationService extends SystemService
|
|||||||
oldPkgState.getUserStates();
|
oldPkgState.getUserStates();
|
||||||
int oldUserStatesSize = oldUserStates.size();
|
int oldUserStatesSize = oldUserStates.size();
|
||||||
if (oldUserStatesSize > 0) {
|
if (oldUserStatesSize > 0) {
|
||||||
ArraySet<String> newWebDomains = mCollector.collectValidAutoVerifyDomains(newPkg);
|
ArraySet<String> newWebDomains = mCollector.collectAllWebDomains(newPkg);
|
||||||
for (int oldUserStatesIndex = 0; oldUserStatesIndex < oldUserStatesSize;
|
for (int oldUserStatesIndex = 0; oldUserStatesIndex < oldUserStatesSize;
|
||||||
oldUserStatesIndex++) {
|
oldUserStatesIndex++) {
|
||||||
int userId = oldUserStates.keyAt(oldUserStatesIndex);
|
int userId = oldUserStates.keyAt(oldUserStatesIndex);
|
||||||
|
|||||||
@@ -617,6 +617,60 @@ class DomainVerificationPackageTest {
|
|||||||
assertThat(service.queryValidVerificationPackageNames()).containsExactly(pkgName)
|
assertThat(service.queryValidVerificationPackageNames()).containsExactly(pkgName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun migratePackageSelected() {
|
||||||
|
val pkgName = PKG_ONE
|
||||||
|
val pkgBefore = mockPkgSetting(pkgName, UUID_ONE, SIGNATURE_ONE,
|
||||||
|
listOf(DOMAIN_1), listOf(DOMAIN_2))
|
||||||
|
val pkgAfter = mockPkgSetting(pkgName, UUID_TWO, SIGNATURE_TWO,
|
||||||
|
listOf(DOMAIN_1), listOf(DOMAIN_2))
|
||||||
|
|
||||||
|
val map = mutableMapOf<String, PackageSetting>()
|
||||||
|
val service = makeService { map[it] }
|
||||||
|
service.addPackage(pkgBefore)
|
||||||
|
|
||||||
|
// Only insert the package after addPackage call to ensure the service doesn't access
|
||||||
|
// a live package inside the addPackage logic. It should only use the provided input.
|
||||||
|
map[pkgName] = pkgBefore
|
||||||
|
|
||||||
|
assertThat(service.setStatus(UUID_ONE, setOf(DOMAIN_1), STATE_SUCCESS))
|
||||||
|
.isEqualTo(DomainVerificationManager.STATUS_OK)
|
||||||
|
|
||||||
|
assertThat(service.setUserSelection(UUID_ONE, setOf(DOMAIN_2), true, USER_ID))
|
||||||
|
.isEqualTo(DomainVerificationManager.STATUS_OK)
|
||||||
|
|
||||||
|
service.getInfo(pkgName).run {
|
||||||
|
assertThat(identifier).isEqualTo(UUID_ONE)
|
||||||
|
assertThat(hostToStateMap).containsExactlyEntriesIn(mapOf(
|
||||||
|
DOMAIN_1 to STATE_SUCCESS,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
assertThat(service.getUserState(pkgName).hostToStateMap).containsExactlyEntriesIn(mapOf(
|
||||||
|
DOMAIN_1 to DOMAIN_STATE_VERIFIED,
|
||||||
|
DOMAIN_2 to DOMAIN_STATE_SELECTED,
|
||||||
|
))
|
||||||
|
assertThat(service.queryValidVerificationPackageNames()).containsExactly(pkgName)
|
||||||
|
|
||||||
|
// Now remove the package because migrateState shouldn't use it either
|
||||||
|
map.remove(pkgName)
|
||||||
|
|
||||||
|
service.migrateState(pkgBefore, pkgAfter)
|
||||||
|
|
||||||
|
map[pkgName] = pkgAfter
|
||||||
|
|
||||||
|
service.getInfo(pkgName).run {
|
||||||
|
assertThat(identifier).isEqualTo(UUID_TWO)
|
||||||
|
assertThat(hostToStateMap).containsExactlyEntriesIn(mapOf(
|
||||||
|
DOMAIN_1 to STATE_SUCCESS,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
assertThat(service.getUserState(pkgName).hostToStateMap).containsExactlyEntriesIn(mapOf(
|
||||||
|
DOMAIN_1 to DOMAIN_STATE_VERIFIED,
|
||||||
|
DOMAIN_2 to DOMAIN_STATE_SELECTED,
|
||||||
|
))
|
||||||
|
assertThat(service.queryValidVerificationPackageNames()).containsExactly(pkgName)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun backupAndRestore() {
|
fun backupAndRestore() {
|
||||||
// This test acts as a proxy for true user restore through PackageManager,
|
// This test acts as a proxy for true user restore through PackageManager,
|
||||||
@@ -798,7 +852,8 @@ class DomainVerificationPackageTest {
|
|||||||
pkgName: String,
|
pkgName: String,
|
||||||
domainSetId: UUID,
|
domainSetId: UUID,
|
||||||
signature: String,
|
signature: String,
|
||||||
domains: List<String> = listOf(DOMAIN_1, DOMAIN_2),
|
autoVerifyDomains: List<String> = listOf(DOMAIN_1, DOMAIN_2),
|
||||||
|
otherDomains: List<String> = listOf(),
|
||||||
isSystemApp: Boolean = false
|
isSystemApp: Boolean = false
|
||||||
) = mockThrowOnUnmocked<PackageSetting> {
|
) = mockThrowOnUnmocked<PackageSetting> {
|
||||||
val pkg = mockThrowOnUnmocked<AndroidPackage> {
|
val pkg = mockThrowOnUnmocked<AndroidPackage> {
|
||||||
@@ -806,21 +861,23 @@ class DomainVerificationPackageTest {
|
|||||||
whenever(targetSdkVersion) { Build.VERSION_CODES.S }
|
whenever(targetSdkVersion) { Build.VERSION_CODES.S }
|
||||||
whenever(isEnabled) { true }
|
whenever(isEnabled) { true }
|
||||||
|
|
||||||
|
fun baseIntent(domain: String) = ParsedIntentInfo().apply {
|
||||||
|
addAction(Intent.ACTION_VIEW)
|
||||||
|
addCategory(Intent.CATEGORY_BROWSABLE)
|
||||||
|
addCategory(Intent.CATEGORY_DEFAULT)
|
||||||
|
addDataScheme("http")
|
||||||
|
addDataScheme("https")
|
||||||
|
addDataPath("/sub", PatternMatcher.PATTERN_LITERAL)
|
||||||
|
addDataAuthority(domain, null)
|
||||||
|
}
|
||||||
|
|
||||||
val activityList = listOf(
|
val activityList = listOf(
|
||||||
ParsedActivity().apply {
|
ParsedActivity().apply {
|
||||||
domains.forEach {
|
autoVerifyDomains.forEach {
|
||||||
addIntent(
|
addIntent(baseIntent(it).apply { autoVerify = true })
|
||||||
ParsedIntentInfo().apply {
|
}
|
||||||
autoVerify = true
|
otherDomains.forEach {
|
||||||
addAction(Intent.ACTION_VIEW)
|
addIntent(baseIntent(it).apply { autoVerify = false })
|
||||||
addCategory(Intent.CATEGORY_BROWSABLE)
|
|
||||||
addCategory(Intent.CATEGORY_DEFAULT)
|
|
||||||
addDataScheme("http")
|
|
||||||
addDataScheme("https")
|
|
||||||
addDataPath("/sub", PatternMatcher.PATTERN_LITERAL)
|
|
||||||
addDataAuthority(it, null)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user