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

Commit 5ccb9e30 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix domain verification shell command "all" params" into sc-dev

parents 69b9601c 907ad40d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1756,6 +1756,11 @@ public class PackageManagerService extends IPackageManager.Stub
        public boolean filterAppAccess(String packageName, int callingUid, int userId) {
            return mPmInternal.filterAppAccess(packageName, callingUid, userId);
        }
        @Override
        public int[] getAllUserIds() {
            return mUserManager.getUserIds();
        }
    }
    /**
+3 −0
Original line number Diff line number Diff line
@@ -358,5 +358,8 @@ public interface DomainVerificationManagerInternal extends DomainVerificationMan

        @Nullable
        AndroidPackage getPackageLocked(@NonNull String pkgName);

        @UserIdInt
        int[] getAllUserIds();
    }
}
+22 −20
Original line number Diff line number Diff line
@@ -423,12 +423,8 @@ public class DomainVerificationService extends SystemService
                for (int pkgStateIndex = 0; pkgStateIndex < pkgStateSize; pkgStateIndex++) {
                    DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(pkgStateIndex);
                    if (userId == UserHandle.USER_ALL) {
                        SparseArray<DomainVerificationUserState> userStates =
                                pkgState.getUserSelectionStates();
                        int userStatesSize = userStates.size();
                        for (int userStateIndex = 0; userStateIndex < userStatesSize;
                                userStateIndex++) {
                            userStates.valueAt(userStateIndex)
                        for (int aUserId : mConnection.getAllUserIds()) {
                            pkgState.getOrCreateUserSelectionState(aUserId)
                                    .setLinkHandlingAllowed(allowed);
                        }
                    } else {
@@ -436,7 +432,6 @@ public class DomainVerificationService extends SystemService
                                .setLinkHandlingAllowed(allowed);
                    }
                }

            }
        } else {
            synchronized (mLock) {
@@ -500,28 +495,33 @@ public class DomainVerificationService extends SystemService

    @Override
    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 {
        mEnforcer.assertInternal(mConnection.getCallingUid());


        if (packageName == null) {
            synchronized (mLock) {
                Set<String> validDomains = new ArraySet<>();

                int size = mAttachedPkgStates.size();
                for (int index = 0; index < size; index++) {
                    DomainVerificationPkgState pkgState = mAttachedPkgStates.valueAt(index);
                    String pkgName = pkgState.getPackageName();
                    PackageSetting pkgSetting = mConnection.getPackageSettingLocked(pkgName);
                    if (pkgSetting == null || pkgSetting.getPkg() == null) {
                    AndroidPackage pkg = pkgSetting == null ? null : pkgSetting.getPkg();
                    if (pkg == null) {
                        continue;
                    }

                    if (domains == null) {
                        validDomains = mCollector.collectAllWebDomains(pkg);
                    } else {
                        validDomains.clear();
                        validDomains.addAll(domains);
                    }

                    setDomainVerificationUserSelectionInternal(userId, pkgState,
                            pkgSetting.getPkg(), enabled, validDomains);
                            pkg, enabled, validDomains);
                }
            }
        } else {
@@ -532,12 +532,16 @@ public class DomainVerificationService extends SystemService
                }

                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);
                }

                Set<String> validDomains =
                        domains == null ? mCollector.collectAllWebDomains(pkg) : domains;

                setDomainVerificationUserSelectionInternal(userId, pkgState, pkgSetting.getPkg(),
                        enabled, domains);
                        enabled, validDomains);
            }
        }

@@ -549,12 +553,10 @@ public class DomainVerificationService extends SystemService
            boolean enabled, Set<String> domains) {
        domains.retainAll(mCollector.collectAllWebDomains(pkg));

        SparseArray<DomainVerificationUserState> userStates =
                pkgState.getUserSelectionStates();
        if (userId == UserHandle.USER_ALL) {
            int size = userStates.size();
            for (int index = 0; index < size; index++) {
                DomainVerificationUserState userState = userStates.valueAt(index);
            for (int aUserId : mConnection.getAllUserIds()) {
                DomainVerificationUserState userState =
                        pkgState.getOrCreateUserSelectionState(aUserId);
                if (enabled) {
                    userState.addHosts(domains);
                } else {
+6 −2
Original line number Diff line number Diff line
@@ -250,6 +250,10 @@ public class DomainVerificationShell {
            return false;
        }

        if (domains.size() == 1 && domains.contains("all")) {
            domains = null;
        }

        try {
            mCallback.setDomainVerificationUserSelectionInternal(userId,
                    packageName, enabled, domains);
@@ -446,10 +450,10 @@ public class DomainVerificationShell {
         * @param packageName the package whose state to change, or all packages if non is
         *                    specified
         * @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,
                @Nullable String packageName, boolean enabled, @NonNull ArraySet<String> domains)
                @Nullable String packageName, boolean enabled, @Nullable ArraySet<String> domains)
                throws PackageManager.NameNotFoundException;

        /**