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

Commit 59e96e14 authored by Adam He's avatar Adam He
Browse files

Reset the whitelist helper for augmented autofill and content capture

when service changes.

Fixes: 128911798
Test: atest CtsContentCaptureServiceTestCases
Test: atest
android.autofillservice.cts.augmented.AugmentedLoginActivityTest

Change-Id: If63b1d1419637764557c87b4e960d6ef32160594
parent a967066a
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -1149,6 +1149,7 @@ final class AutofillManagerServiceImpl
                mRemoteAugmentedAutofillService.destroy();
                mRemoteAugmentedAutofillService = null;
                mRemoteAugmentedAutofillServiceInfo = null;
                resetAugmentedAutofillWhitelistLocked();
            }

            final boolean available = isAugmentedAutofillServiceAvailableLocked();
@@ -1180,6 +1181,7 @@ final class AutofillManagerServiceImpl
     *
     * @return whether caller UID is the augmented autofill service for the user
     */
    @GuardedBy("mLock")
    boolean setAugmentedAutofillWhitelistLocked(List<String> packages,
            List<ComponentName> activities, int callingUid) {

@@ -1267,10 +1269,20 @@ final class AutofillManagerServiceImpl
                Slog.v(TAG, "whitelisting packages: " + packages + "and activities: " + components);
            }
            mAugmentedWhitelistHelper.setWhitelist(packages, components);
            mRemoteAugmentedAutofillService = getRemoteAugmentedAutofillServiceLocked();
        }
    }

    /**
     * Resets the augmented autofill whitelist.
     */
    @GuardedBy("mLock")
    void resetAugmentedAutofillWhitelistLocked() {
        if (mMaster.verbose) {
            Slog.v(TAG, "resetting augmented autofill whitelist");
        }
        whitelistForAugmentedAutofillPackages(null, null);
    }

    private void sendStateToClients(boolean resetClient) {
        final RemoteCallbackList<IAutoFillManagerClient> clients;
        final int userClientCount;
+12 −1
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ final class ContentCapturePerUserService
            if (mMaster.debug) Slog.d(TAG, "updateRemoteService(): destroying old remote service");
            mRemoteService.destroy();
            mRemoteService = null;
            resetContentCaptureWhitelistLocked();
        }

        // Updates the component name
@@ -551,6 +552,17 @@ final class ContentCapturePerUserService
        return null;
    }

    /**
     * Resets the content capture whitelist.
     */
    @GuardedBy("mLock")
    private void resetContentCaptureWhitelistLocked() {
        if (mMaster.verbose) {
            Slog.v(TAG, "resetting content capture whitelist");
        }
        mWhitelistHelper.setWhitelist((List) null, null);
    }

    private final class ContentCaptureServiceRemoteCallback extends
            IContentCaptureServiceCallback.Stub {

@@ -567,7 +579,6 @@ final class ContentCapturePerUserService
            synchronized (mLock) {
                mWhitelistHelper.setWhitelist(packages, activities);
            }
            // TODO(b/119613670): log metrics
        }

        @Override