Merge "Fix domain verification shell command "all" params" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5ccb9e300c
@@ -1756,6 +1756,11 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
public boolean filterAppAccess(String packageName, int callingUid, int userId) {
|
public boolean filterAppAccess(String packageName, int callingUid, int userId) {
|
||||||
return mPmInternal.filterAppAccess(packageName, callingUid, userId);
|
return mPmInternal.filterAppAccess(packageName, callingUid, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getAllUserIds() {
|
||||||
|
return mUserManager.getUserIds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -358,5 +358,8 @@ public interface DomainVerificationManagerInternal extends DomainVerificationMan
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
AndroidPackage getPackageLocked(@NonNull String pkgName);
|
AndroidPackage getPackageLocked(@NonNull String pkgName);
|
||||||
|
|
||||||
|
@UserIdInt
|
||||||
|
int[] getAllUserIds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,12 +423,8 @@ public class DomainVerificationService extends SystemService
|
|||||||
for (int pkgStateIndex = 0; pkgStateIndex < pkgStateSize; pkgStateIndex++) {
|
for (int pkgStateIndex = 0; pkgStateIndex < pkgStateSize; pkgStateIndex++) {
|
||||||
DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(pkgStateIndex);
|
DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(pkgStateIndex);
|
||||||
if (userId == UserHandle.USER_ALL) {
|
if (userId == UserHandle.USER_ALL) {
|
||||||
SparseArray<DomainVerificationUserState> userStates =
|
for (int aUserId : mConnection.getAllUserIds()) {
|
||||||
pkgState.getUserSelectionStates();
|
pkgState.getOrCreateUserSelectionState(aUserId)
|
||||||
int userStatesSize = userStates.size();
|
|
||||||
for (int userStateIndex = 0; userStateIndex < userStatesSize;
|
|
||||||
userStateIndex++) {
|
|
||||||
userStates.valueAt(userStateIndex)
|
|
||||||
.setLinkHandlingAllowed(allowed);
|
.setLinkHandlingAllowed(allowed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -436,7 +432,6 @@ public class DomainVerificationService extends SystemService
|
|||||||
.setLinkHandlingAllowed(allowed);
|
.setLinkHandlingAllowed(allowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
@@ -500,28 +495,33 @@ public class DomainVerificationService extends SystemService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDomainVerificationUserSelectionInternal(@UserIdInt int userId,
|
public void setDomainVerificationUserSelectionInternal(@UserIdInt int userId,
|
||||||
@Nullable String packageName, boolean enabled, @NonNull ArraySet<String> domains)
|
@Nullable String packageName, boolean enabled, @Nullable ArraySet<String> domains)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
mEnforcer.assertInternal(mConnection.getCallingUid());
|
mEnforcer.assertInternal(mConnection.getCallingUid());
|
||||||
|
|
||||||
|
|
||||||
if (packageName == null) {
|
if (packageName == null) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
Set<String> validDomains = new ArraySet<>();
|
Set<String> validDomains = new ArraySet<>();
|
||||||
|
|
||||||
int size = mAttachedPkgStates.size();
|
int size = mAttachedPkgStates.size();
|
||||||
for (int index = 0; index < size; index++) {
|
for (int index = 0; index < size; index++) {
|
||||||
DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(index);
|
DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(index);
|
||||||
String pkgName = pkgState.getPackageName();
|
String pkgName = pkgState.getPackageName();
|
||||||
PackageSetting pkgSetting = mConnection.getPackageSettingLocked(pkgName);
|
PackageSetting pkgSetting = mConnection.getPackageSettingLocked(pkgName);
|
||||||
if (pkgSetting == null || pkgSetting.getPkg() == null) {
|
AndroidPackage pkg = pkgSetting == null ? null : pkgSetting.getPkg();
|
||||||
|
if (pkg == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (domains == null) {
|
||||||
|
validDomains = mCollector.collectAllWebDomains(pkg);
|
||||||
|
} else {
|
||||||
validDomains.clear();
|
validDomains.clear();
|
||||||
validDomains.addAll(domains);
|
validDomains.addAll(domains);
|
||||||
|
}
|
||||||
|
|
||||||
setDomainVerificationUserSelectionInternal(userId, pkgState,
|
setDomainVerificationUserSelectionInternal(userId, pkgState,
|
||||||
pkgSetting.getPkg(), enabled, validDomains);
|
pkg, enabled, validDomains);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -532,12 +532,16 @@ public class DomainVerificationService extends SystemService
|
|||||||
}
|
}
|
||||||
|
|
||||||
PackageSetting pkgSetting = mConnection.getPackageSettingLocked(packageName);
|
PackageSetting pkgSetting = mConnection.getPackageSettingLocked(packageName);
|
||||||
if (pkgSetting == null || pkgSetting.getPkg() == null) {
|
AndroidPackage pkg = pkgSetting == null ? null : pkgSetting.getPkg();
|
||||||
|
if (pkg == null) {
|
||||||
throw DomainVerificationUtils.throwPackageUnavailable(packageName);
|
throw DomainVerificationUtils.throwPackageUnavailable(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<String> validDomains =
|
||||||
|
domains == null ? mCollector.collectAllWebDomains(pkg) : domains;
|
||||||
|
|
||||||
setDomainVerificationUserSelectionInternal(userId, pkgState, pkgSetting.getPkg(),
|
setDomainVerificationUserSelectionInternal(userId, pkgState, pkgSetting.getPkg(),
|
||||||
enabled, domains);
|
enabled, validDomains);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,12 +553,10 @@ public class DomainVerificationService extends SystemService
|
|||||||
boolean enabled, Set<String> domains) {
|
boolean enabled, Set<String> domains) {
|
||||||
domains.retainAll(mCollector.collectAllWebDomains(pkg));
|
domains.retainAll(mCollector.collectAllWebDomains(pkg));
|
||||||
|
|
||||||
SparseArray<DomainVerificationUserState> userStates =
|
|
||||||
pkgState.getUserSelectionStates();
|
|
||||||
if (userId == UserHandle.USER_ALL) {
|
if (userId == UserHandle.USER_ALL) {
|
||||||
int size = userStates.size();
|
for (int aUserId : mConnection.getAllUserIds()) {
|
||||||
for (int index = 0; index < size; index++) {
|
DomainVerificationUserState userState =
|
||||||
DomainVerificationUserState userState = userStates.valueAt(index);
|
pkgState.getOrCreateUserSelectionState(aUserId);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
userState.addHosts(domains);
|
userState.addHosts(domains);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -250,6 +250,10 @@ public class DomainVerificationShell {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (domains.size() == 1 && domains.contains("all")) {
|
||||||
|
domains = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mCallback.setDomainVerificationUserSelectionInternal(userId,
|
mCallback.setDomainVerificationUserSelectionInternal(userId,
|
||||||
packageName, enabled, domains);
|
packageName, enabled, domains);
|
||||||
@@ -446,10 +450,10 @@ public class DomainVerificationShell {
|
|||||||
* @param packageName the package whose state to change, or all packages if non is
|
* @param packageName the package whose state to change, or all packages if non is
|
||||||
* specified
|
* specified
|
||||||
* @param enabled whether the domain is now approved by the user
|
* @param enabled whether the domain is now approved by the user
|
||||||
* @param domains the set of domains to change
|
* @param domains the set of domains to change, or null to affect all domains
|
||||||
*/
|
*/
|
||||||
void setDomainVerificationUserSelectionInternal(@UserIdInt int userId,
|
void setDomainVerificationUserSelectionInternal(@UserIdInt int userId,
|
||||||
@Nullable String packageName, boolean enabled, @NonNull ArraySet<String> domains)
|
@Nullable String packageName, boolean enabled, @Nullable ArraySet<String> domains)
|
||||||
throws PackageManager.NameNotFoundException;
|
throws PackageManager.NameNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user